• News

• Industries

• Learning & Support

• Community

• Marketplace

# Float in Blueprint value not expected

Hey there. Im new to blueprint and programming in generally so if this is something obvious im sry for that.

Im currently working on a project and have come by something i dont seem to understand.
I have made a new project with a new blueprint file and recreated the scenario.
Shortly explain i loop 15 times and for each time i add 0.001 to a float.
The float starts at 1
Whenthe loop comes to 1.01 and 0.001 is added it says : 1.011001 on my screen.
I have uploaded some screenshots that may help explain.

If i set the value to 1.01 and add 0.001 the result is 1.011 which i expect. However not when i do the looping.

Would be grateful for help.

Edit:Picture of Bp is easier to see now i hope

Yeah, computers are not good at math. It’s a rounding error you need to learn to live with.

This node may be of use at times.

Blueprints don’t offer more precise floating point data types. If you need it more precise, you need to use C++.

But I doubt you do, if you tell use what you’re trying to do, we might help you.

Ok, thx for the explaination guys.
I was trying to use this to loop through a csv data table with the main index(or whatever its called) being: 1.00,1.001, 1.002 and so on. I tried use c++ for datatable but failed at it,hehe, so i went for blueprint but i guess im back to start then.
But how come the precision of float being more precise with a single 1.01 + 1.001 compared to iterating/looping and adding 1.001?

You can format your number so that it always has 3 digits after the point: