rust-lang / rust-lang/rustc_apfloat
Overflow flag when result is larget finite value
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 23
- Forks
- 16
- Avg merge
- 6h 52m
- Merged PRs (30d)
- 1
Description
IeeeFloat::overflow_result ( in src/ieee.rs) returns Status::INEXACT alone on the finite-result path.
IEEE 754-2019 7.4 requires the overflow whenever the largest finite number is exceeded in magnitude by what would have been the rounded floating point result with an unbounded exponent range.
Whether the default result subsequently produced by the selected rounding mode is infinity or the largest finite value does not change whether overflow occurred.
In particular, the specification details overflow for roundTowardZero and roundTowardNegative even with a non inf result.
use rustc_apfloat::ieee::Quad;
use rustc_apfloat::{Float, Round, Status, StatusAnd};
fn main() {
let x = Quad::largest();
let StatusAnd { status, value } = x.mul_r(x, Round::TowardZero);
println!("value : {value:?}");
println!("status: {status:?}");
}
Observed:
value : 1.18973149535723176508575932662800702E+4932(Normal | +[10384593717069655257060992658440191] * 2^16383)
status: Status(INEXACT)
Expected:
value : 1.18973149535723176508575932662800702E+4932(Normal | +[10384593717069655257060992658440191] * 2^16383)
status: Status(OVERFLOW | INEXACT)
This is related to the following LLVM issue: https://github.com/llvm/llvm-project/issues/220018
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/ieee.rs at IeeeFloat::overflow_result and reproduce the provided Quad::largest multiplication with Round::TowardZero. Check the finite-result path and compare its status with the IEEE 754-2019 requirement, including the stated non-infinity case. Done means the result remains the largest finite value while the status includes both OVERFLOW and INEXACT.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100