Separate Printing Mantissa and Exponent of a Floating Point
"Nordlöw" via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Aug 13 04:15:29 PDT 2014
On Wednesday, 13 August 2014 at 07:58:40 UTC, Nordlöw wrote:
> {
> float x = 1.23e10;
> auto y = *cast(FloatRep*)(&x);
> writeln(y.fraction, ", ",
> y.exponent, ", ",
> y.sign);
> }
>
> {
> double x = 1.23e10;
> auto y = *cast(DoubleRep*)(&x);
> writeln(y.fraction, ", ",
> y.exponent, ", ",
> y.sign);
> }
> }
It would be nice to turn these into either
- properties or at least
- template overloads
if possible as pointer casting unsafe and error-prone.
More information about the Digitalmars-d-learn
mailing list