Skip to main content

flush_subnormal_f32

Function flush_subnormal_f32 

Source
pub fn flush_subnormal_f32(v: f32, mode: Rounding) -> f32
Expand description

Flush a subnormal result to zero or to the smallest normal, per FCSR.FS.

Which one depends on the rounding mode, and that is the part most easily got wrong: “flush to zero” is the whole story only for round-to-nearest and toward-zero. A directed mode that rounds away from zero must deliver the smallest normal of that sign instead, because zero is on the wrong side of the true result.

n64-systemtest pins all four: a tiny negative result gives -0 under nearest, toward-zero and toward-+inf, and -f32::MIN_POSITIVE under toward--inf.