[PR #7770] Fix /time argument and /compute round: exact Math.round(float) #7808

Open
opened 2026-11-03 07:24:29 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7770
Author: @Joansitoh
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: fix/6901-6902-math-round-float


📝 Commits (1)

  • b91722a Math.round(float) exactness for /time arguments and /compute round

📊 Changes

7 files changed (+57 additions, -22 deletions)

View changed files

📝 Cargo.lock (+1 -0)
📝 crates/horizon-client-render/src/mipmap.rs (+2 -17)
📝 crates/horizon-client/src/game/commands/compute.rs (+1 -2)
📝 crates/horizon-command/Cargo.toml (+1 -0)
📝 crates/horizon-command/src/args.rs (+1 -2)
📝 crates/horizon-command/src/tests.rs (+16 -0)
📝 crates/horizon-core/src/jmath.rs (+35 -1)

📄 Description

🤖 Opened by Joansitoh's AI agent (Claude Code, Sonnet 5.5), not by Joansitoh personally.

What

/time arguments (0.49999997t) and /compute round rounded 0.49999997 up to 1 because x + 0.5 was computed in f32 (= 1.0). Both now use a bit-exact Math.round(float): new horizon_core::jmath::round_f32 (moved from the private java_round in mipmap.rs, which now calls it). horizon-command gets a horizon-core dependency (no cycle).

Vanilla reference

  • TimeArgument.java:51 Math.round(value * factor)
  • Round.java:18 Math.round(...getFloatUnsafe(context))

How tested

  • jmath test: 0.49999997→0, 0.5→1, -0.5→0, 2.5→3, -2.5→-2, ±1e10 saturate, NaN→0, 8388609→8388609.
  • horizon-command test: time set 0.49999997t → 0, 0.5t → 1, time add -2.5t → -2.
  • Harnesses command_parse, command_exec: PASS.

pr_ready --quick (upstream/main bc761767d): Public tree ✅, Python tests ✅ 614, rustfmt ✅, clippy ✅, doc tests ✅, content root tests ✅ 24, mod API ✅, launcher rustfmt ✅. Workspace tests ❌: horizon-client-render --lib SIGSEGV (gfx, this machine's GPU; the mipmap tests pass when run alone). Launcher clippy/tests ❌: system fontconfig missing here (environment).

Remaining affected harnesses: run by CI's parity job.

Fixes #6901
Fixes #6902

Suggested label: none

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/7770 **Author:** [@Joansitoh](https://github.com/Joansitoh) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/6901-6902-math-round-float` --- ### 📝 Commits (1) - [`b91722a`](https://github.com/horizon-rust/horizon/commit/b91722abcddc4b334b22335d15c1976e012cc07f) Math.round(float) exactness for /time arguments and /compute round ### 📊 Changes **7 files changed** (+57 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+1 -0) 📝 `crates/horizon-client-render/src/mipmap.rs` (+2 -17) 📝 `crates/horizon-client/src/game/commands/compute.rs` (+1 -2) 📝 `crates/horizon-command/Cargo.toml` (+1 -0) 📝 `crates/horizon-command/src/args.rs` (+1 -2) 📝 `crates/horizon-command/src/tests.rs` (+16 -0) 📝 `crates/horizon-core/src/jmath.rs` (+35 -1) </details> ### 📄 Description > 🤖 Opened by Joansitoh's AI agent (Claude Code, Sonnet 5.5), not by Joansitoh personally. ## What `/time` arguments (`0.49999997t`) and `/compute` `round` rounded 0.49999997 up to 1 because `x + 0.5` was computed in f32 (= 1.0). Both now use a bit-exact `Math.round(float)`: new `horizon_core::jmath::round_f32` (moved from the private `java_round` in `mipmap.rs`, which now calls it). `horizon-command` gets a `horizon-core` dependency (no cycle). ## Vanilla reference - `TimeArgument.java:51` `Math.round(value * factor)` - `Round.java:18` `Math.round(...getFloatUnsafe(context))` ## How tested - `jmath` test: 0.49999997→0, 0.5→1, -0.5→0, 2.5→3, -2.5→-2, ±1e10 saturate, NaN→0, 8388609→8388609. - `horizon-command` test: `time set 0.49999997t` → 0, `0.5t` → 1, `time add -2.5t` → -2. - Harnesses `command_parse`, `command_exec`: PASS. pr_ready --quick (upstream/main bc761767d): Public tree ✅, Python tests ✅ 614, rustfmt ✅, clippy ✅, doc tests ✅, content root tests ✅ 24, mod API ✅, launcher rustfmt ✅. Workspace tests ❌: `horizon-client-render --lib` SIGSEGV (gfx, this machine's GPU; the `mipmap` tests pass when run alone). Launcher clippy/tests ❌: system `fontconfig` missing here (environment). Remaining affected harnesses: run by CI's parity job. Fixes #6901 Fixes #6902 Suggested label: none 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#7808
No description provided.