Christopher D . Lewis wrote:
> Someone posted a question as to the size of number which a scalar
> would tolerate.  When I wanted to know what size boundaries I faced in
> certain variable types in C, I wrote a little program that added 1 to
> a variable until n+1 was less than n, at which point I concluded the
> variable had been rolled over to its start again.  Perl seems to
> tolerate quite a bit of this, as the app has been churning away,
> printing every so many number just to let me know where it's at, and
> it recently went past two hundred billion (I cheated and am
> incrementing by 1000 instead of 1, because I got impatient
> incrementing by one). $scalars in perl handle big numbers ... and
> maybe Perl notices when a boundary is being crossed and reconstitutes
> the number?

As others have noted, Perl will change to double-precision
representation
when it can no longer express the number in integer format.

The sort of program you have written will work if you 'use integer' at
the top of the code. My machine runs WinXPPro and my values wrap
at 2_147_483_647, or 31 bits.

To get an idea how many significant decimal floating-point digits can be
stored you can write something like this:

    printf "%50.40f", 1/3;

Again, on my machine this shows 16.5 digits.

HTH,

Rob






-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to