I create a var(float) “UsedTime” in the Character BP. On Eventtick => Delay 0.1 => Then usedTime+0.1.
Works fine.
Now create a new BP, just a floating text.
In the Graph:
Eventtick => Cast To myChar get UsedTime => UsedTime * 10 => Round (UsedTime) => So I reveice an Int (for example 240).
Then I divide this Int by 10 and receive a Float (24,0, right?)
This float is about 30-40% of the either 23.9999 or 24.00001 (Printed directly via PrintString)
I looked at some points via “Print String”, and it is the division 240 / 10 that makes 23.9999.
Maybe I am doing something wrong (I can post BP Pics later when I am at home)?
Anybody seen something like this?
Thank you for the Link!
I get an idea of the “problem”. But to really understand I need to read this a few times.
Is there a simple way around? I just need a simple lap timer.
to put it simple: your computer is just not able to represent decimal values in an accurate way.
And he is doing mistakes the whole you run your computer, the reason why you dont see any mistakes usually is that f.e. your operating system can handle occuring errors that happen.
So for the future every you are working with floats,doubles or whatever… just never try to check if two decimal variables are “==”. And if you divide some decimal values never expect them to have the value you would have when you solve it on a piece of paper
full seconds aren’t exact enough, I need 1/10 seconds.
So I thought “take a float, since Int is a round number”.
Float = something around 24.567 (what ever) * 10 = 245 /10 : = 24.5(float) // Print this and I’m done.
If I understand you correct, I will make an int, (logically defined as 1/10 of a second) and add 1 every 0.1 seconds.
A value of 245 represents 24.5 seconds
Then I need to update my "Display " BPs, to format it as xx**.**x.
This way I don’t have to handle with floats and it will work fine (as far as I think ).
You probably don’t need to worry about floats for now. However do keep in mind that you need to learn it in the future.
If the counter is going to run for about 100 hours you will have some problems