Overflow flag when result is larget finite value

Open Beginner friendly
#36 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
compilers

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.

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

Dominant language
Rust
Stars
23
Forks
16
Avg merge
6h 52m
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-lang/rustc_apfloat

All issues in rust-lang/rustc_apfloat

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.