lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>>How do I round number to x decimal places eg to round 12.50000009  to
>>12.5?
>
>Easy!  Multiply the number by a power of 10 to get all of the digits you
>want to keep above the decimal point.  Truncate it to an integer.  Then
>divide to get everything back where it started

Or use format("%."..digits.."f",x).
--lhf