ucrt: step nexttowardf toward its double target #50
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/50"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Repla09 on 2026-11-26T11:31:01Z.
nexttowardftakes its target as a double (long doubleisdoublehere) so that a target between two floats still movesxone float toward it. The host rounded the target to a float first, which can round it toxitself:nexttowardf(1.0f, 1.0 + 1e-10)returned1.0finstead of the next float up, andnexttowardf(0.0f, 1e-300)returned 0.Now it compares as doubles and steps toward the infinity on the target's side.
nexttowardf_steps_toward_its_double_targetfails without the fix (1065353216 != 1065353217) and covers both directions, zero toward a tiny target, equal values, overflow and NaN.Testing
cargo test --target x86_64-apple-darwin -p victory-hlepasses (220 unit, 15 native_probe; the D3D12 probe test skipped, no Metal Shader Converter here).x86_64-apple-darwinshows no new warnings;rustfmt --checkandcargo xtask policypass.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T11:42:42Z.
Review: CHANGES_REQUESTED
The double-precision direction fix looks good: the original near-equal case fails on main and passes here. Two things:
errnoon overflow. When a finite float steps to infinity, set guesterrnotoERANGE, including when the target is infinite (ucrt/math.rs:~202; Microsoft documentsERANGEfor this). Please extend the overflow assertion to checkerrno, and add an opposite-signed-zero case.long double= 64-bitdoubleABI in the UCRT section ofdocs/native-host.md.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Repla09 on 2026-11-26T11:50:15Z.
Thanks. In
0557feea finite float stepping to infinity sets ERANGE, including toward an infinite target (an infinity in does not). The test checks errno for those cases and adds opposite-signed zeros (nexttowardf(0.0, -0.0)is -0.0 and the reverse +0.0). native-host.md notes the Windows x64long double= 64-bitdoubleABI. Rebased onto main.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T12:01:56Z.
Review: APPROVED
Thanks for addressing the earlier requests; the regression passes under Rosetta and fails against main. Approved.