Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Re: time() function

by IraTarball (Monk)
on Sep 28, 2001 at 18:07 UTC ( #115461=note: print w/replies, xml ) Need Help??

in reply to Re: time() function
in thread time() function

So, I understand this is true. I'm O.K. with overflows. I can handle overflows. But why does
$var = time * 1000;
overflow and
$var = time; $var *= 1000;
not overflow?

I believe that on my system (Win2k, perl 5.6.1) integers are 32 bit, just like returned by time() I verified this with print ($var&(~0)) which gives me (2**32)-1.

Does perl automatically decide (not) to use BigInts? Any ideas?


"So... What do all these little arrows mean?"

Replies are listed 'Best First'.
Re: Re: Re: time() function
by tachyon (Chancellor) on Sep 28, 2001 at 18:48 UTC

    time() is a Perl function, implemented in C with 32 bit (long int) math relevant to the unix epoch.

    A perl scalar is an interesting beast (also implemented in C) that can hold a string or a number or a reference so is not directly comparable to a short, int, long, float, double, char in C. It is in fact a struct. Have a look at this code and perlman:perlguts. On the Win95 box in front of me Perl will represent up to 2**49 (562,949,953,421,312) as an integer before resorting to scientific notation.

    for ( 0..64 ) { $var = 2**$_; print "Perl can do 2**$_ : $var\n"; }




Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2019-05-20 05:34 GMT
Find Nodes?
    Voting Booth?
    Do you enjoy 3D movies?

    Results (123 votes). Check out past polls.