decimal precision
Posted: 03 Sep 2011, 16:13
val = val/60 -- convert to minutes
val = val*10 -- shift the decimal place
val = (math.floor(val))/10 -- truncate and reshift
So then I output the results
40.166667938232
401.66668701172
40.099998474121<-wtf
well I investigated it. The math floor operation does work but when I divide by ten it adds back all the decimal places...
does lua have a shift that I can use or a precision since the division is flawed?
val = val*10 -- shift the decimal place
val = (math.floor(val))/10 -- truncate and reshift
So then I output the results
40.166667938232
401.66668701172
40.099998474121<-wtf
well I investigated it. The math floor operation does work but when I divide by ten it adds back all the decimal places...
does lua have a shift that I can use or a precision since the division is flawed?