Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: krysber on December 10, 2015, 11:31:15 PM

Title: [!Solved!] Adding/subtracting to a float variable.
Post by: krysber on December 10, 2015, 11:31:15 PM
I have a loop that repeats thirty two times subtracting .01 from a float variable. The problem is that when the variable is 2.72, I end up with 2.080001 after deleting .01 thirty two times. This happens at different values where I end up with odd numbers like -4.649992 and such. Is there a better way to do this math?
Title: Re: Adding/subtracting to a float variable.
Post by: Gida on December 11, 2015, 02:41:42 AM
Sound like a rounding issue to me. Have you tried doin it with bigger numbers? Instead of subtracting constantly 0.01 you could multiply your floats with 100 before the math operations. if required, divide by 100 at the end.
Title: Re: Adding/subtracting to a float variable.
Post by: krysber on December 11, 2015, 03:02:33 PM
I tried with the same effect. I solved it by using integers to do the math then converting to float.