[Tutor] Range limited?
dman
dsh8290@rit.edu
Mon, 30 Jul 2001 13:34:21 -0400
On Mon, Jul 30, 2001 at 01:12:36PM -0400, fleet@teachout.org wrote:
| On Mon, 30 Jul 2001, Danny Yoo wrote:
|
| > > PS: Should the above be
| > > "while long(i) < upper-bound-of-many-digit-number"?
| > > Will "i" go flaky after 16 digits or is it sufficient that only one number
| > > be long?
| >
| > Theoretically, it shouldn't go flaky because 'long' integers are of
| > unlimited length. Let's see, how many atoms are there in the universe?
|
| If the expression is 'while i < upper-bound-of-many-digit-number' (ie, i
| is not long), then i appears to have an upper limit of 2147483647.
For your system. It will always be sys.maxint. Here's some data from
some of the interpreters I have access to :
Python 2.1 (#1, Apr 17 2001, 09:45:01)
[GCC 2.95.3-2 (cygwin special)] on cygwin_nt-4.01
Type "copyright", "credits" or "license" for more information.
>>> import sys ; print sys.maxint
2147483647
>>>
Jython 2.0 on java1.1.8 (JIT: none)
Type "copyright", "credits" or "license" for more information.
>>> import sys ; print sys.maxint
2147483647
>>>
Python 2.0 (#18, Oct 31 2000, 13:55:49) [C] on sunos5
Type "copyright", "credits" or "license" for more information.
>>> import sys ; print sys.maxint
2147483647
>>>
Python 2.1 (#1, Jul 27 2001, 15:48:55)
[GCC 2.95.2 19991024 (release)] on sunos5
Type "copyright", "credits" or "license" for more information.
>>> import sys ; print sys.maxint
2147483647
>>>
So apparently that is the maximum for an integer on Intel PII systems
(widows -- cygwin and java) and whatever SPARC is in an Ultra 10
(Solaris 8).
If you had an older machine it would be less (like maybe on a 386 or
definitely a 286) or if you have a newer machine it will be more (such
as the 64-bit SPARCs or the new IA-64).
-D