Formating floating point/double for display

BlitzMax Forums/BlitzMax Programming/Formating floating point/double for display

Its actually quite simple to convert to fixed point math, round there and convert it back, assuming you use numbers in a reasonable size (ie number * 10^decimals < MaxFloat, if this does not hold, just make float to double and int to long)

function fRound:float(number:float,decimals:int)
 local t:int = 10^decimals
 local result:float = int(number * t + 0.5)
 return result / t
end function


There are most likely simpler and especially less breaking ways, but so far I didn't have reason to use them.