Skip to content

Overflow flag when result is larget finite value #36

Description

@Garfield1002

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: llvm/llvm-project#220018

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions