If you use %s, you asked Perl to stringify the value so it does that, in the way you saw, evidently with e-notation.
%d tells Perl to convert it to a signed integer; 32-bit signed integers (which may have been the norm in 2001 when this was asked) can only count up to about 2e9, i.e. a 10-digit number, and I believe it will overflow to -1 as you saw. Even a 64-bit signed (%ld) would top out at 8e18, which is a 19-digit decimal number.
%f (as recommended by another reply) tells Perl to treat the number as floating-point, and hopefully a double-precision one. That has a 53-bit mantissa, which can handle up to about 8e15 (a 16-digit number).
%Lf would be a long double (which in C99 only means "at least double precision"); on x86 CPUs this is generally an 80-bit number, with a 63-bit mantissa, which can go up to 8e18 (same as a signed 64-bit integer).
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.