Skip to content
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

Implement ties-to-even for Big[U]Int::to_{f32,f64} #271

Merged
merged 2 commits into from
Aug 22, 2023

Commits on Aug 22, 2023

  1. Implement ties-to-even for Big[U]Int::to_{f32,f64}

    BigUInt::to_{f32,f64} uses only the highest 64 bits as the mantissa,
    discarding the rest, which gives an incorrect result when later
    converted to float using IEEE-754's default nearest-ties-to-even
    rounding.
    
    Fixed to use correct round-to-odd for taking the mantissa, which means
    setting the LSB to 1 if any of the lower (i.e. rounded away) bits are 1.
    
    This also fixes the problem for BigInt since it really just uses BigUInt
    under the hood.
    dramforever authored and cuviper committed Aug 22, 2023
    Configuration menu
    Copy the full SHA
    5b6955b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    907fc19 View commit details
    Browse the repository at this point in the history