GodotBigNumberClass
GodotBigNumberClass copied to clipboard
roundDown() not quite working as expected
Ex: Big.new(275.75).roundDown().toString() giving 276
I think it's because snapped(mantissa, precision) is rounding to the nearest multiple of precision, not down.
I'm not sure if it's actually a good fix but I replaced mantissa = snapped(mantissa, precision) with mantissa = floor(mantissa * (1/precision)) * precision
Apologies for formatting and/or if I wasn't supposed to submit an issue about this, still learning github.
Edit-- my original reply said your method doesn't work. My toScientific() method was rounding the text. Looks like your method is good!
Side note: I asked AI for help, and it came up with, instead of your solution, mantissa = floor(mantissa / precision) * precision
. So it just swapped the order of multiplication and division. Kinda funny!
I'm not sure if it's actually a good fix but I replaced mantissa = snapped(mantissa, precision) with mantissa = floor(mantissa * (1/precision)) * precision
Did mantissa = floor(mantissa / precision) * precision
instead, since the 1 / precision
is unnecessary:
74076d2