ucrt: print %a with the CRT's default precision of 13 #73

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

@⁠Olima34 on GitHub · 2026-11-26 13:41 UTC · original
Olima34:fix/ucrt-printf-hex-precision → main · +9 −3 · 1 files · 2 commits · merged 2026-11-26 15:29 UTC

What this changes

Without a precision, %a trimmed the trailing zeros of the mantissa as glibc does (0x1p+0). Microsoft's format specification gives a, A "Default precision is 13", so the CRT writes 0x1.0000000000000p+0. A precision of 0 still drops the point unless # is given. The %a cases of the existing format test are updated, and %.0a / %#.0a are added.

How it was tested

  • cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory (all pass, native probe tests included)
  • 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 files touched (host_posix is not built for Windows)
  • arm64 cargo test --workspace and cargo xtask policy
  • The new test fails on main and passes with the change
  • 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 (none here)
  • New diagnostics are behind a VICTORY_* variable and documented (none added)
**@⁠Olima34** on GitHub · 2026-11-26 13:41 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/73) `Olima34:fix/ucrt-printf-hex-precision` → `main` · +9 −3 · 1 files · 2 commits · merged 2026-11-26 15:29 UTC ## What this changes Without a precision, `%a` trimmed the trailing zeros of the mantissa as glibc does (`0x1p+0`). [Microsoft's format specification](https://learn.microsoft.com/en-us/cpp/c-runtime-library/format-specification-syntax-printf-and-wprintf-functions) gives `a`, `A` "Default precision is 13", so the CRT writes `0x1.0000000000000p+0`. A precision of 0 still drops the point unless `#` is given. The `%a` cases of the existing format test are updated, and `%.0a` / `%#.0a` are added. ## How it was tested - [x] `cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory` (all pass, native probe tests included) - [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 files touched (`host_posix` is not built for Windows) - [x] arm64 `cargo test --workspace` and `cargo xtask policy` - [x] The new test fails on `main` and passes with the change - [ ] 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 (none here) - [x] New diagnostics are behind a `VICTORY_*` variable and documented (none added)
Without a precision, %a trimmed the trailing zeros of the mantissa as glibc does (0x1p+0). Microsoft's format specification gives a, A a default precision of 13, so the CRT writes 0x1.0000000000000p+0; a precision of 0 still drops the point unless # is given.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:45:15 +00:00
Author
Owner

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

%a with the default precision of 13 matches UCRT, and %.0a / %#.0a are covered. Thanks.

**@⁠LakshanSivakumar** on GitHub · 2026-11-26 14:55 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/73#pullrequestreview-6076266351) · **approved these changes** %a with the default precision of 13 matches UCRT, and %.0a / %#.0a are covered. Thanks.
github manually merged commit fea5a0fecc into main 2026-11-26 15:35:00 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.