Skip to content

Fix ToInt64RoundZero edge cases, add Sin/Cos/Tan and tests, update README#6

Merged
jenska merged 1 commit intomainfrom
codex/review-code-changes
Mar 29, 2026
Merged

Fix ToInt64RoundZero edge cases, add Sin/Cos/Tan and tests, update README#6
jenska merged 1 commit intomainfrom
codex/review-code-changes

Conversation

@jenska
Copy link
Copy Markdown
Owner

@jenska jenska commented Mar 29, 2026

Motivation

  • Correct incorrect behavior and sign/overflow handling in the ToInt64RoundZero conversion for edge cases and shifting semantics.
  • Provide basic trigonometric helpers (Sin, Cos, Tan) for the X80 type to broaden the math API.
  • Add unit tests to cover the new conversion behavior and trig functions, and update documentation to advertise the new APIs.

Description

  • Fixed ToInt64RoundZero in conversions.go by reordering the overflow/edge-case branch, returning math.MinInt64 for the exact negative-int64 boundary, adjusting the shift to avoid sign-extension (aSig >> (-shiftCount)), and ensuring exceptions are raised correctly.
  • Added Sin, Cos, and Tan methods to operations.go that return NaN for NaN inputs and otherwise call the standard library via math.Sin, math.Cos, and math.Tan with conversions to/from float64.
  • Imported math where required and updated tests: added TestX80_ToInt64RoundZero and TestX80_SinCosTan in conversions_test.go and operations_test.go respectively to validate behavior and NaN/Infinity handling.
  • Updated readme.md to document the new trig methods and the round-toward-zero conversion variants (ToInt32RoundZero, ToInt64RoundZero).

Testing

  • Ran unit tests with go test ./... covering conversions and operations including TestX80_ToInt64RoundZero and TestX80_SinCosTan.
  • All automated tests completed successfully.

Codex Task

@jenska jenska merged commit 1e85392 into main Mar 29, 2026
13 of 14 checks passed
@jenska jenska deleted the codex/review-code-changes branch March 29, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant