473,327 Members | 1,997 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,327 software developers and data experts.

Variable over 2147483647?

Just a quick question, how do you go about storing an integer over 2147483647 (2^31-1)?
May 13 '07 #1
13 6121
ilikepython
844 Expert 512MB
Just a quick question, how do you go about storing an integer over 2147483647 (2^31-1)?
You can use an unsigned long or a long long. An unsigned long's maxium size is twice that of a regular long. However, it only stores positive values. If you really need a big number, use a long long or an unsigned long long.
Check here if you are interested:
http://msdn2.microsoft.com/en-us/lib...tz(VS.80).aspx
May 13 '07 #2
Is there any way to store a number above 18,446,744,073,709,551,615?
May 13 '07 #3
ilikepython
844 Expert 512MB
Is there any way to store a number above 18,446,744,073,709,551,615?
No, I don't believe you can. That uses 64 bits and not many computers today even support that much. Only lately did processors came out as 64 bit. Why would you want to though? That's 18 quintillion!
May 13 '07 #4
DeMan
1,806 1GB
You can store numbers as big as you like....(we use numbers as long as 128 Bytes (1024bit) in cryptography, and I'm sure there are systems that use at least twice that again)
There is, however no primitive type defined to handle these. At the end of the day, any number is a series of bits. How you do calculations with them may cause headaches, because you kind of have to define that yourself.......
Some math libraries have BigInteger (Unless I'm thinking Java) which is a non-primitive type. I'm not sure how big a number this can play with, though.

In terms of storing the integer, what is the harm in using text as you did....
123,456,789,123,456,789,123,456,789,123,456,789,12 3,456,789,123,456,789
That number is bigger than 18,446,744,073,709,551,615 and is stored easily....interpreting it as a number may be another matter thoguh....
May 13 '07 #5
Does anyone know how variables are stored in python, because , for all i know, there is no restriction on variables in python.
May 13 '07 #6
You can store numbers as big as you like....(we use numbers as long as 128 Bytes (1024bit) in cryptography, and I'm sure there are systems that use at least twice that again)
Could you please explain this.
An RSA Key pair generation generates large prime INTEGERS and then after calculation it returns a 128 byte array (BYTE).
there are 2048 bit keys and even more used in practical.
but i dont know why you compare this when we talk about integers.
May 14 '07 #7
DeMan
1,806 1GB
The byte stream (or array) that you mention is treated as a single integer. Just like an int is not (usually) a byte (it's more commonly 2 or 4 bytes). Similarly, in RSA, the key used is of HUGE size - 1024 I have usually worked with, but I am aware of larger values being used also.
These 128bytes are stored in a contiguous 'lump' of memory. The actual calculations made with them, are done as though this is one LARGE number (which it is).
Essentially what I am saying, is that it is possibly to create numbers of arbitrary length, as long as you understand how to implement it.

If you were simply asking about primitive types, I apologise, I assumed you were interestedc in knowing how big a number you could use (or more specifically store). The limit in this is bound only by the overhead/complexity of implementing it.
May 14 '07 #8
AdrianH
1,251 Expert 1GB
Does anyone know how variables are stored in python, because , for all i know, there is no restriction on variables in python.
They may use strings. Try the python forum for more info.


Adrian
May 14 '07 #9
AdrianH
1,251 Expert 1GB
The byte stream (or array) that you mention is treated as a single integer. Just like an int is not (usually) a byte (it's more commonly 2 or 4 bytes). Similarly, in RSA, the key used is of HUGE size - 1024 I have usually worked with, but I am aware of larger values being used also.
These 128bytes are stored in a contiguous 'lump' of memory. The actual calculations made with them, are done as though this is one LARGE number (which it is).
Essentially what I am saying, is that it is possibly to create numbers of arbitrary length, as long as you understand how to implement it.

If you were simply asking about primitive types, I apologise, I assumed you were interestedc in knowing how big a number you could use (or more specifically store). The limit in this is bound only by the overhead/complexity of implementing it.
Hey Man, what does interestedc mean? Didn't find it in any dictionary.

Adrian
May 14 '07 #10
DeMan
1,806 1GB
Its a variation on interested. It means interested in a c related topic
May 14 '07 #11
AdrianH
1,251 Expert 1GB
Its a variation on interested. It means interested in a c related topic
I think we have a thread about such usage as that. Look at the Expert's Panel under "To the keeper of the FAQ..."


Adrian
May 14 '07 #12
I think we have a thread about such usage as that. Look at the Expert's Panel under "To the keeper of the FAQ..."


Adrian
I'm pretty new to the forms, can you post a link to the article?
May 15 '07 #13
AdrianH
1,251 Expert 1GB
I'm pretty new to the forms, can you post a link to the article?
Sorry, Mods and Admins only. It has to do with using shortforms and such. Not really related to this thread.


Adrian
May 15 '07 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

134
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
7
by: Faree | last post by:
Hi all, I am doing portal for storing info of visitors.it is working well too.but my prob is with mysql..when i entered infoa bt thier phone numbers ,fax or mobile numbers,soemtimes it is...
6
by: Jack Wasserstein | last post by:
how come when i add two Int32 vars in a try catch statement with the value of 2147483647 it results in -2 instead of an exception?
1
by: Shawn | last post by:
As if it won't be clear enough from my code, I'm pretty new to C programming. This code is being compiled with an ANSI-C compatible compiler for a microcontroller. That part, I believe, will be...
25
by: gamehack | last post by:
Hi all, I'm writing an application which will be opening binary files with definite sizes for integers(2 byte integers and 4 byte longs). Is there a portable way in being sure that each integer...
20
by: Manuel | last post by:
hi, I have a problem, a stupid problem. I can't declare a variable of type byte. The g++ said that i have syntactic error in this line. The code is this: byte * variable; well, i think...
29
by: garyusenet | last post by:
I'm trying to investigate the maximum size of different variable types. I'm using INT as my starting variable for exploration. I know that the maximum number that the int variable can take is:...
1
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause...
7
by: Virtual_X | last post by:
I am new to c++ and i know that "short int" size is 2bytes with rang -32768 to 32767 and "int" size is 4bytes with rang -2147483648 to 2147483647 How!! the "int" range must be ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.