in reply to Re: Engineering FP notation & sprintf
in thread Engineering FP notation & sprintf

Hm. That's a different interpretation of "engineering notation". The basic requirement is that the characteristic (exponent) is always a power of 3. Eg. 6.66e+29 --> 6.660000e+29 should be 666.0e27.

Other examples:


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP PCW It is as I've been saying!(Audio until 20090817)

Replies are listed 'Best First'.
Re^3: Engineering FP notation & sprintf
by toolic (Bishop) on Nov 16, 2009 at 21:40 UTC
    For future reference... I finally found some time to package up the ideas in this thread and upload to CPAN
    use warnings; use strict; use Number::FormatEng qw(format_eng); for my $num qw(1.23e2 1.234 1234.56 1234567 6.66e+29) { printf "%-10s -> %-10s\n", $num, format_eng($num); } __END__ 1.23e2 -> 123 1.234 -> 1.234 1234.56 -> 1.23456e3 1234567 -> 1.234567e6 6.66e+29 -> 666e27
    Comments and reviews are more than welcome.