Hello all,
I have been programming in Python only for a month or so and have stumbled
over a "problem" that I could not solve through rtfm.
$ python
Python 2.2.2 (#1, Nov 6 2003, 09:19:47)
[GCC 3.3] on irix646
Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
>>> ulong_max=18446 744073709551615
>>> type(ulong_max)[/color][/color][/color]
<type 'long'>[color=blue][color=green][color=darkred]
>>> print ulong_max[/color][/color][/color]
184467440737095 51615[color=blue][color=green][color=darkred]
>>> very_long_long= 184467440737095 516151844674407 3709551615
>>> type(very_long_ long)[/color][/color][/color]
<type 'long'>[color=blue][color=green][color=darkred]
>>> print very_long_long[/color][/color][/color]
184467440737095 516151844674407 3709551615[color=blue][color=green][color=darkred]
>>> result=very_lon g_long/15
>>> type(result)[/color][/color][/color]
<type 'long'>[color=blue][color=green][color=darkred]
>>> print result[/color][/color][/color]
122978293824730 344101229782938 247303441[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
I have set ulong_max above to the C compilers ULONG_MAX definition from limits.h
I would have expected Python to complain when setting the value of the variable
very_long_long to anything greater than ULONG_MAX.
Since I am currently doing computations with integer values *much* bigger than
ULONG_MAX, this behaviour suites me, but I am wondering if this is a "standard"
Python behaviour since I do not want my scripts to become dependant on some
obscure non-standard feature...
Could any kind Python-Guru please shed some light on this?
Also, if Python really can handle longs that are bigger than the machines native
longs, the interpreter has to do some sort of arbitrary precision math
somewhere. Could you please point me to the according interpreter's source file(s)?
TIA + Regards,
S.Susnjar
I have been programming in Python only for a month or so and have stumbled
over a "problem" that I could not solve through rtfm.
$ python
Python 2.2.2 (#1, Nov 6 2003, 09:19:47)
[GCC 3.3] on irix646
Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
>>> ulong_max=18446 744073709551615
>>> type(ulong_max)[/color][/color][/color]
<type 'long'>[color=blue][color=green][color=darkred]
>>> print ulong_max[/color][/color][/color]
184467440737095 51615[color=blue][color=green][color=darkred]
>>> very_long_long= 184467440737095 516151844674407 3709551615
>>> type(very_long_ long)[/color][/color][/color]
<type 'long'>[color=blue][color=green][color=darkred]
>>> print very_long_long[/color][/color][/color]
184467440737095 516151844674407 3709551615[color=blue][color=green][color=darkred]
>>> result=very_lon g_long/15
>>> type(result)[/color][/color][/color]
<type 'long'>[color=blue][color=green][color=darkred]
>>> print result[/color][/color][/color]
122978293824730 344101229782938 247303441[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
I have set ulong_max above to the C compilers ULONG_MAX definition from limits.h
I would have expected Python to complain when setting the value of the variable
very_long_long to anything greater than ULONG_MAX.
Since I am currently doing computations with integer values *much* bigger than
ULONG_MAX, this behaviour suites me, but I am wondering if this is a "standard"
Python behaviour since I do not want my scripts to become dependant on some
obscure non-standard feature...
Could any kind Python-Guru please shed some light on this?
Also, if Python really can handle longs that are bigger than the machines native
longs, the interpreter has to do some sort of arbitrary precision math
somewhere. Could you please point me to the according interpreter's source file(s)?
TIA + Regards,
S.Susnjar
Comment