Separate Printing Mantissa and Exponent of a Floating Point
Justin Whear via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Aug 11 08:30:30 PDT 2014
On Mon, 11 Aug 2014 13:47:13 +0000, Nordlöw wrote:
> Is there a way to separately stringify/print the mantissa and exponent
> of a floating point?
>
> I want this in my pretty-printing module to produce something like
>
> 1.2 \cdot 10^3
>
> instead of
>
> 1.2e3
>
> I could of course always split on the e but that is kind of non-elegant,
> I believe.
If you're writing your own pretty-printer, you can extract those pieces
using FloatRep[1] and print them however you like.
1. http://dlang.org/phobos/std_bitmanip.html#.FloatRep
More information about the Digitalmars-d-learn
mailing list