Skip to content

Group basic float ops #2302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bobzhang
Copy link
Contributor

Summary

  • combine pow and mod into arithmetic.mbt
  • gather advanced float operations into advanced.mbt
  • update NOTICE for the new file

Testing

  • moon check
  • moon test
  • moon bundle
  • moon info

https://chatgpt.com/codex/tasks/task_e_6854fb6d60088320981673ab33e4a66c

Copy link

Code duplication in length validation checks

Category
Maintainability
Code Snippet
if ui << 1 < 0x33800000U << 1
Recommendation
Consider extracting commonly used bit manipulation checks into helper functions with descriptive names
Reasoning
The code has several bit manipulation patterns that are repeated. Creating helper functions would improve readability and reduce potential errors when maintaining these checks.

Some magic numbers lack clear documentation

Category
Correctness
Code Snippet
let b1 : UInt = 709958130 // B1 = (127-127.0/3-0.03306235651)*2**23
Recommendation
Add more detailed comments explaining the mathematical derivation of magic numbers or create named constants with clear documentation
Reasoning
While some magic numbers have comments, the mathematical reasoning behind them is not immediately clear. Better documentation would help future maintainers understand the implementation details.

Multiple floating-point conversions in arithmetic operations

Category
Performance
Code Snippet
(self.to_double() % other.to_double()).to_float()
Recommendation
Consider implementing the operations directly on Float when possible to avoid conversion overhead
Reasoning
Converting between Float and Double types adds overhead. For simple operations, direct Float implementation might be more efficient if precision allows.

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 7396

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 89.886%

Totals Coverage Status
Change from base Build 7394: 0.0%
Covered Lines: 8505
Relevant Lines: 9462

💛 - Coveralls

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.

2 participants