Float Calculations issue

I have an issue were I am trying to subtract from a large float by a small number, ie 1,000,000,000 - 0.11 using an event tick. When I run it, it doesn’t work. When I try 1,000,000,000 - 36, it will count down. What am I doing wrong?

These are all floats.

Yeah, it won’t work because floats can only be so big. You won’t be able to set it to 1 000 000 000.1. Looks like the inaccuracy’s of a float get changed to 0 after the decimal point in UE4 while in pure C++ you would get random values. Perhaps you will need to use a couple of floats to store your number. I would suggest making a class to store your big number.

What are you trying to do with these massive floats?

yes, with the rounding/accuracy comments. It does also sound like you are doing it on Tick, which means that it deducts the value every frame… which will count down… here you would use something like a DoOnce node

This is the correct answer. If you look here you can see they say:

float has 7 decimal digits of
precision

So a value like 913,362.5 is probably Ok (7 digits), but 913,362.11 is not (8 digits)

Unfortunately, the root of this problem is that basically all GPUs use only floats and integers for the sake of performance. If you use C++ you could use a double variable instead, but when it comes time to actually move or render the object, you’ll need to convert it to floating point again anyways and still need to deal with the accuracy limitations.

As a work-around: if the variable you are using represents something like time, you could express the value in milliseconds using an int (the maximum value of an int is 2,147,483,647) with the catch that all time values will be rounded to the nearest millisecond. Alternatively, Unreal has a TimeSpan object that you can use instead: Timespan | Unreal Engine 5.2 Documentation

Everyone seems to be overlooking the fact that a massive float probably isn’t what it is needed here…

Based off all the information I am seeing here, I now see that I am going to need switch to a c++ class for my calculations and make strings out of the doubles to help call them in BP.

Thank you again for everyones help on this!

In C++ and Java, we have two in-built data types, float and double, to represent all floating-point numbers, but there is always confusion about which data type to choose as both are supposed to do the same work.

It usually occupies 32 bits in the computer memory with 4 bytes. An integer can have a maximum value of 2,147,483,647, whereas an float can have a maximum value of 3.4028235 × 1038. Also, a float can provide six digits after the decimal point and know more about the [difference between float and double][1].

[1]: