Just float imprecision.
You would need to clean up the float or use a more broader value of it.
Just float imprecision.
You would need to clean up the float or use a more broader value of it.
Hi everyone!
I created a function to round my floats with a desired number of decimals.
The math are simple : for example, I take F = 125.56894210.
Calcul :
F*100 = 12556.894210
Round = 12556
Round / 100 = 125.56
But sometimes, for a unknown reason, the calcul fail! For exemple I take F = 17.44168 and I get 17.440001
I did exactly the same calculation with nodes :
I tried a simple division and the safe division (sometimes I need to divide by 0 in my function). I watched all the values. The problem is outside the divide node.
Any idea?
Thank you for help!
Hi @TheKaosSpectrum Thank you for your answer!
Oh, I suspected that… I don’t need a great precision at all so I would like to clean it up.
Can you tell me what is your best method to clean the float in blueprint?
Thank you!
Well i don’t normally just clean it up, unless i want whole number, then i use ceil or floor. Normally i just do checking on the first two part of the float after the decimal, ie in your example, i would be comparing just 17.44 and ignoring the other stuff.
http://www.interkaos.com/grabs/UE4Editor-Win64-DebugGame_5OS5EHnseb.png
Where the top float is your calculation, the bottom float is your matching.
Ok I see. But If I try to round with decimals it is for display purpose. There is a simple way to keep only some decimals, other than string edition (split and co)?
Thank you!
use FText Format Float
Oh yes! I didn’t see all the options at the bottom of the node! I can delete my functions for that ah ah
Thank you very much!