ucrt: step nexttowardf toward its double target #50
No reviewers
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS!50
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/50/head"
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?
@Repla09 on GitHub · 2026-11-26 11:31 UTC · original
Repla09:fix/ucrt-nexttowardf-double-target→main· +49 −1 · 2 files · 3 commits · merged 2026-11-26 12:05 UTCnexttowardftakes 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.@LakshanSivakumar on GitHub · 2026-11-26 11:42 UTC · original · requested changes
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.@Repla09 on GitHub · 2026-11-26 11:50 UTC · original
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.@LakshanSivakumar on GitHub · 2026-11-26 12:01 UTC · original · approved these changes
Thanks for addressing the earlier requests; the regression passes under Rosetta and fails against main. Approved.