in reply to How to control no. of digits on exponent

Weird.

I get the same output (1.23e-004) with "perl 5, version 12, subversion 0 (v5.12.0) built for MSWin32-x86-multi-thread" (Strawbery Perl on Vista x64).

But with "perl, v5.10.1 (*) built for i686-cygwin-thread-multi-64int" on the same machine and "perl 5, version 12, subversion 1 (v5.12.1) built for x86_64-linux-thread-multi" in an x64 virtual machine, I get 1.23e-04.

Replies are listed 'Best First'.
Re^2: How to control no. of digits on exponent
by chrestomanci (Priest) on Dec 31, 2010 at 08:52 UTC

    I suspect that those details of the formatting of a printf string come from the underlying C library's implementation of printf, rather than from perl.

    The printf layout on cygwin matches what I am getting on my linux box, which makes sense, as both use GCC libraries underneath. I would have thought Strawbery Perl would be the same.

    As ikegami said, you could do string processing on the raw output of sprintf, to get the number of digits you want. The problem of course is that the raw number may need all those digits of exponent because it is very large or small.