Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Why does printf() do this to big numbers?

by almut (Canon)
on Mar 17, 2010 at 09:26 UTC ( [id://829126]=note: print w/replies, xml ) Need Help??


in reply to Re: Why does printf() do this to big numbers?
in thread Why does printf() do this to big numbers?

On pretty much any platform out there, int is 32 bits

Not necessarily.  With a "64-bit perl", "%d" can handle ints larger than 32 bits just fine:

$ perl -e "printf qq(%d\n), 2810337464" 2810337464
$ perl -V ... intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +6 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', + lseeksize=8 ... Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP THREADS_HAVE_PIDS USE_64_BIT_ +ALL USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES ...

Replies are listed 'Best First'.
Re^3: Why does printf() do this to big numbers?
by fullermd (Priest) on Mar 18, 2010 at 00:25 UTC

    Ah, true. I guess my C-brain leaks through sometimes :) I guess that's probably the USE_64_BIT_INT.

    But at any rate, overflow is what the OP is seeing.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://829126]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-25 14:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found