473,836 Members | 1,358 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 16807
tj*****@gmail.c om 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...@island training.comwro te:
tjhn...@gmail.c om 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_functio ns as cf
for k in xrange(1,20):
a = cf.Type12MH(k,1 )
print 'number of digits in generation %2d:' %
(k),cf.gmpy.num digits(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#1 2>", line 2, in <module>
a = cf.Type12MH(k,1 )
File "C:\Program Files\PyGTK\Pyt hon\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.c omwrote:
tjhn...@gmail.c om 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...@island training.comwro te:
>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#1 2>", line 2, in <module>
a = cf.Type12MH(k,1 )
File "C:\Program Files\PyGTK\Pyt hon\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.a r>
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...@island training.comwro te:
tjhn...@gmail.c om 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#1 2>", line 2, in <module>
* * a = cf.Type12MH(k,1 )
* File "C:\Program Files\PyGTK\Pyt hon\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\use r>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\use r>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.c om 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
100274
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 issue somewhat; it uses __int64 in some places (with a comment about strict) but freely uses 'long long' in other places. In any case, these standard library headers are supposed to be 'standard' w.r.t. C and C++ aren't they? How can a standard...
7
3612
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 example, consider this four-bit number: 1100 from this number I want to extract two numbers: 1000 and 100 had the four-bit number been 0101 I would want to extract 100 and 1. How should I do this? I wish I had some code to post but I don't...
9
3958
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
9541
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 use "long long" integer type(64 bit), but it seems that Oracle doesn't like it after execution, and giving me error code -1460, any idea about this? thx
21
2831
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 convenient (and for some things possibly necessary) to use long long integer and/or unsigned long long integer variables. How widely supported are these variable types? How long ago were they introduced? I notice they are not mentioned in K&R #2.
12
13554
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 sprintf(pHex,"%0X",9987967441778573855). But it only returns 8
2
7284
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 single line with "\n" in the middle, or I could use multiple cout and endl. But I just feel more readable if I can have the whole paragraph as a string. Thanks,
21
2658
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), sometimes int and long int are the same, and long long int is twice the width; or sometimes both long int and long long int are twice the width of int. This apparently all quite normal according to my c99 draft and c-faq.com. However it doesn't...
10
3842
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
2770
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++){ long long int k = 1<<i; cout<<i<<"\t"<<k<<"\t"<<sizeof(k)<<"\n"; }
0
9813
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10835
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10541
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10585
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9367
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7785
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5818
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4447
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4007
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.