in reply to Perl Problems with Digit Precision Changing on the Printf Statement

The problem is that you're stringifying the number at the wrong point. If you print the number as a string (%s20), it will pad with whitespace. If you print the number as a number, it will pad with zeros. If you want 19 decimal places, you would use something like "%.19f". Try that and you'll see what I mean.

The documentation for sprintf explains format strings as used by sprintf and printf.

Also, for high-precision floating point, you may find it more reliable to use Math::BigInt.


Dave

  • Comment on Re: Perl Problems with Digit Precision Changing on the Printf Statement