Logo

Programming-Idioms

  • C#
  • Rust

Idiom #248 Construct a 64-bit floating-point value

Construct the "double precision" (64-bit) floating point number d from the mantissa m, the exponent e and the sign flag s (true means the sign is negative).

let d = if s { -1.0 } else { 1.0 } * m as f64 * 2.0f64.powf(e as f64);
d = (s?-1:1) * m * double.Exp10(e);
  if (s) then
    d = -m * radix(d)**e
  else
    d =  m * radix(d)**e
  end if


New implementation...
< >
Bart