Forum Discussion
belltown
7 years agoRoku Guru
Due to the way floating point numbers are implemented, your number could be "9.899999", in which case your function will return "9.8" when it should return "9.9".
I'd do something like this (assuming your numbers are stored internally as Doubles, but you want to print them to one significant decimal place):
I'd do something like this (assuming your numbers are stored internally as Doubles, but you want to print them to one significant decimal place):
function convert(f as double) as string
a = CInt(f * 10)
n = a \ 10
m = abs(a) mod 10
return n.toStr() + "." + m.toStr()
end function