ucrt: ilogb of a NaN is FP_ILOGBNAN, INT_MAX, as in the CRT #97

Manually merged
github merged 2 commits from github-bot/gh-97 into main 2026-11-26 15:27:56 +00:00 AGit
Owner

@⁠Olima34 on GitHub · 2026-11-26 14:29 UTC · original
Olima34:fix/ucrt-ilogb-nan → main · +13 −1 · 1 files · 2 commits · merged 2026-11-26 15:23 UTC

What this changes

ilogb called macOS's libm, whose FP_ILOGBNAN equals its FP_ILOGB0, INT_MIN, so a NaN looked like a zero. The CRT's FP_ILOGBNAN is 0x7fffffff (corecrt_math.h), which Microsoft's ilogb reference returns for NaNs and infinities alike; macOS already gives INT_MAX for an infinity. ilogbf follows. New test ilogb_gives_the_crts_special_values.

How it was tested

  • cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory (all pass); the new test fails on main
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings, also with --all-features; clippy for x86_64-apple-darwin reports nothing in the file touched
  • arm64 cargo test --workspace and cargo xtask policy
  • Ran the game: not done, no copy of it here

Checklist

  • No game files, game code, disassembly listings or SDK files are included
  • Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md
  • New diagnostics are behind a VICTORY_* variable and documented (none added)
**@⁠Olima34** on GitHub · 2026-11-26 14:29 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/97) `Olima34:fix/ucrt-ilogb-nan` → `main` · +13 −1 · 1 files · 2 commits · merged 2026-11-26 15:23 UTC ## What this changes `ilogb` called macOS's libm, whose `FP_ILOGBNAN` equals its `FP_ILOGB0`, `INT_MIN`, so a NaN looked like a zero. The CRT's `FP_ILOGBNAN` is `0x7fffffff` (`corecrt_math.h`), which [Microsoft's `ilogb` reference](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/ilogb-ilogbf-ilogbl2) returns for NaNs and infinities alike; macOS already gives `INT_MAX` for an infinity. `ilogbf` follows. New test `ilogb_gives_the_crts_special_values`. ## How it was tested - [x] `cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory` (all pass); the new test fails on `main` - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings`, also with `--all-features`; clippy for `x86_64-apple-darwin` reports nothing in the file touched - [x] arm64 `cargo test --workspace` and `cargo xtask policy` - [ ] Ran the game: not done, no copy of it here ## Checklist - [x] No game files, game code, disassembly listings or SDK files are included - [x] Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md - [x] New diagnostics are behind a `VICTORY_*` variable and documented (none added)
ilogb went straight to macOS's libm, whose FP_ILOGBNAN equals its FP_ILOGB0, INT_MIN, so a NaN looked like a zero. The CRT's FP_ILOGBNAN is 0x7fffffff (corecrt_math.h), which Microsoft's ilogb reference returns for NaNs and infinities alike; macOS already gives INT_MAX for an infinity. ilogbf follows.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:45:56 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-26 14:55 UTC · original · approved these changes

ilogb(NaN) is INT_MAX like the CRT, and ilogbf follows. Thanks.

**@⁠LakshanSivakumar** on GitHub · 2026-11-26 14:55 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/97#pullrequestreview-6076265727) · **approved these changes** ilogb(NaN) is INT_MAX like the CRT, and ilogbf follows. Thanks.
github manually merged commit 1bdfef83ae into main 2026-11-26 15:27:56 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.