473,383 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Max Long

How can I figure out the largest long available? I was hoping for
something like sys.maxint, but I didn't see it. Also, can someone
point me to where I can (concisely) read about size of such types
(int, float, long).
Jan 21 '08 #1
6 16721
tj*****@gmail.com wrote:
How can I figure out the largest long available? I was hoping for
something like sys.maxint, but I didn't see it. Also, can someone
point me to where I can (concisely) read about size of such types
(int, float, long).
There is no explicit (defined) limit. The amount of available address
space forms a practical limit.

Gary Herron

Jan 21 '08 #2
On Jan 21, 5:36*pm, Gary Herron <gher...@islandtraining.comwrote:
tjhn...@gmail.com wrote:
How can I figure out the largest long available? *I was hoping for
something like sys.maxint, but I didn't see it. *Also, can someone
point me to where I can (concisely) read about size of such types
(int, float, long).

There is no explicit (defined) limit. *The amount of available address
space forms a practical limit.
But not the only limitation:
>>import collatz_functions as cf
for k in xrange(1,20):
a = cf.Type12MH(k,1)
print 'number of digits in generation %2d:' %
(k),cf.gmpy.numdigits(a)

number of digits in generation 1: 2
number of digits in generation 2: 9
number of digits in generation 3: 74
number of digits in generation 4: 659
number of digits in generation 5: 5926
number of digits in generation 6: 53328
number of digits in generation 7: 479940
number of digits in generation 8: 4319453
number of digits in generation 9: 38875064
number of digits in generation 10: 349875565

Traceback (most recent call last):
File "<pyshell#12>", line 2, in <module>
a = cf.Type12MH(k,1)
File "C:\Program Files\PyGTK\Python\lib\collatz_functions.py", line
745, in Type12MH
return TWO**(SIX*a - ONE) - ONE
ValueError: mpz.pow outrageous exponent

The power function can't do exponents that have 32 or more bits
even if the memory can hold the resulting number.
>
Gary Herron
Jan 22 '08 #3
On Jan 21, 3:34 pm, Bjoern Schliessmann <usenet-
mail-0306.20.chr0n...@spamgourmet.comwrote:
tjhn...@gmail.com wrote:
How can I figure out the largest long available?

Why would you? AFAIK, longs are only limited by available memory.
Indeed, as the docs pointed out. I guess I was confused by

"If pylong is greater than ULONG_MAX, an OverflowError is raised."

at http://docs.python.org/api/longObjects.html.

Jan 22 '08 #4
En Mon, 21 Jan 2008 22:02:34 -0200, me********@aol.com
<me********@aol.comescribió:
On Jan 21, 5:36*pm, Gary Herron <gher...@islandtraining.comwrote:
>tjhn...@gmail.com wrote:
How can I figure out the largest long available? *I was hoping for

There is no explicit (defined) limit. *The amount of available address
space forms a practical limit.

But not the only limitation:
[...]
Traceback (most recent call last):
File "<pyshell#12>", line 2, in <module>
a = cf.Type12MH(k,1)
File "C:\Program Files\PyGTK\Python\lib\collatz_functions.py", line
745, in Type12MH
return TWO**(SIX*a - ONE) - ONE
ValueError: mpz.pow outrageous exponent

The power function can't do exponents that have 32 or more bits
even if the memory can hold the resulting number.
Isn't it a limitation of the gmpy library, not of the builtin long type?

--
Gabriel Genellina

Jan 22 '08 #5
On Jan 21, 7:42*pm, "Gabriel Genellina" <gagsl-...@yahoo.com.ar>
wrote:
En Mon, 21 Jan 2008 22:02:34 -0200, mensana...@aol.com *
<mensana...@aol.comescribió:


On Jan 21, 5:36*pm, Gary Herron <gher...@islandtraining.comwrote:
tjhn...@gmail.com wrote:
How can I figure out the largest long available? *I was hoping for
There is no explicit (defined) limit. *The amount of available address
space forms a practical limit.
But not the only limitation:
[...]
Traceback (most recent call last):
* File "<pyshell#12>", line 2, in <module>
* * a = cf.Type12MH(k,1)
* File "C:\Program Files\PyGTK\Python\lib\collatz_functions.py", line
745, in Type12MH
* * return TWO**(SIX*a - ONE) - ONE
ValueError: mpz.pow outrageous exponent
The power function can't do exponents that have 32 or more bits
even if the memory can hold the resulting number.

Isn't it a limitation of the gmpy library, not of the builtin long type?
Well, gmpy for sure. But as for Python's builtin
longs, I wouldn't know as I've only got one lifetime.

Python longs

c:\python25\user>long_ago.py
1 2 0.0310001373291
2 9 0.0310001373291
3 74 0.0310001373291
4 659 0.0620000362396
5 5926 0.0620000362396
6 53328 0.219000101089
7 479940 63.5620000362
8 4319453 8983.07800007
9 <aborted after 8 hours - at this rate,
it will take 796 years to finish generation 11>

GMPY longs

c:\python25\user>long_ago.py
1 2 0.0
2 9 0.0160000324249
3 74 0.0160000324249
4 659 0.0160000324249
5 5926 0.0160000324249
6 53328 0.0160000324249
7 479940 0.0160000324249
8 4319453 0.0320000648499
9 38875064 0.15700006485
10 349875565 1.36000013351

>
--
Gabriel Genellina- Hide quoted text -

- Show quoted text -
Jan 22 '08 #6
tj*****@gmail.com wrote:
Indeed, as the docs pointed out. I guess I was confused by

"If pylong is greater than ULONG_MAX, an OverflowError is raised."

at http://docs.python.org/api/longObjects.html.
Take care -- this is about "unsigned long" data type of C, not a
Python "long" instance.

Regards,
Björn

--
BOFH excuse #75:

There isn't any problem

Jan 23 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Tim Clacy | last post by:
How is a 64 bit type defined in strict C++? It seems C has support for 'long long' since C99, but not so for C++? Looking through one compiler vendor's standard library headers has clouded the...
7
by: William Payne | last post by:
Hello, I have a variable of type unsigned long. It has a number of bits set (with set I mean they equal one). I need to determine those bits and their position and create new numbers from them. For...
9
by: luke | last post by:
Hi everybody, please, can someone explain me this behaviour. I have the following piece of code: long long ll; unsigned int i = 2; ll = -1 * i; printf("%lld\n", ll);
12
by: wenmang | last post by:
Hi, I am using following Oracle Proc-C compiler: Pro*C/C++: Release 8.1.7.0.0 - Production on Thu Jun 15 15:57:32 2006 (c) Copyright 2000 Oracle Corporation. All rights reserved. I like to...
21
by: Charles Sullivan | last post by:
I maintain/enhance some inherited FOSS software in C which has compiler options for quite a few different Unix-like operating systems, many of which I've never even heard of. It would be...
12
by: Ahmad Jalil Qarshi | last post by:
Hi, I have an integer value which is very long like 9987967441778573855. Now I want to convert it into equivalent Hex value. The result must be 8A9C63784361021F I have used...
2
by: PengYu.UT | last post by:
Hi, In python, triple quote (""") can be used to quote a paragraph (multiple lines). I'm wondering if there is any equivalent in C++. For the following code, I could write the long string in a...
21
by: Bart C | last post by:
I've always had a problem knowing exactly how wide my integer variables were in C, and the little program below has increased my confusion. Run on 3 compilers on the same cpu (32-bit pentium),...
10
by: ratcharit | last post by:
Currently using cosine function in math.h Currently I get: 1 = cos(1e^-7) Is there another way for cos to return value of high accuracy say: 0.999999 = cos(1e^-7)
15
by: Oliver Graeser | last post by:
I need a >49 bit integer type. tried sizeof(long long), says 8. 8 byte = 64 bit right? but when I try to assign a value with more than 32 bit, it fails. To illustrate: for (i=0; i<64; i++){...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.