Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Perl

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).

$d = ($s?-1:1) * "${m}e${e}"; 

Taking advantage of Perl's string interpolation by forming a floating point literal using the mantissa variable, the literal 'e', and the exponent variable.
d = (s?-1:1) * m * double.Exp10(e);

New implementation...
< >
Bart