KSP-KOS / KSLib

The standard library and examples for the Kerboscript language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rounding error in time_formatting from lib_num_to_formatted_str

beeryt opened this issue · comments

It appears that seconds place rounding is truncated.

RUNPATH("/path/to/lib_num_to_formatted_str").
LOCAL value IS 0.999.
PRINT time_formatting(value, 3, 2, TRUE).  // T+ 00.99    should be T+ 01.00
PRINT time_formatting(value, 3, 1, TRUE).  // T+ 00.9     should be T+ 01.0
PRINT time_formatting(value, 3, 0, TRUE).  // T+ 00       should be T+ 01

Not a bug the fact the function is flooring the values is intentional as without using floor I was seeing errors when formatting values like 59.999 as that would result in 0:60.00 and I didn't like that so I made the decision to floor as apposed to round. At worst this is a failure to document fully.