mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-17 15:55:14 +00:00
push_num_places now writes the digits of round(v * 10^places) directly when that integer is below 2^52 in magnitude, placing the decimal point and trimming fractional zeros itself. Below 2^52 the integer is exact and dividing it by 10^places lands within half a decimal step of the exact quotient, so the text is the same as the formatter's. NaN, infinities, scaling overflow and larger rounded values take the existing formatter path unchanged. Requests for more than nine places are still clamped to nine first. Tests compare the output with the formatter path for places 0 to 12 over fixed boundary values (negative zero, ties, 1e15, 2^52, f64::MAX, non-finite values) and about 144,000 values in all (about 48,000 generated, plus the neighboring bit patterns of each). Widening the limit to 2^54 makes the comparison fail, for example -1709448349065955.5 at one place. On 1,200,000 path coordinates at four places (release build, wall clock on a Linux host running other builds at the same time, seven alternating runs), the formatter path took 362 to 373 ms and the integer path 38 to 44 ms.