So I know there is a limit on how long an int varaible can be. Soooo....
Is there a way to make that inf. or at least very very close to inf.?
besides the long int way.
Printable View
So I know there is a limit on how long an int varaible can be. Soooo....
Is there a way to make that inf. or at least very very close to inf.?
besides the long int way.
infinity like more than the amount of space you have on your hard drive. ;)
Think of this way once you've reached the max amount a data type holds you go up to the next. So yeah you'll have to gothen long long....Code:long num
that's the simple answer.
>>Is there a way to make that inf. or at least very very close to inf.?
Depends on what you mean. If you mean extending the built-in datatype, then no unless you want to rewrite your compiler (and then it won't be standard). You can create a class which has the same functionality as an int though, and manually does bit operations on a 2gb char array (dynamically created of course) if you really want. That will get you as close to infinity as you're going to get (2gb will get you an astronomically huge number, assuming you have that much RAM on your computer). In fact, if you want, you can make a datatype of 80gb or more if you store the number in a file. Alternately, and less efficiently, you could do save the number as a string and manually perform operations on the individual digits. However, you'll have trouble using it in conjunction with any functions that use normal datatypes, unless you supply conversion operators which truncate or wrap the number when it's too large, and then return the result. :)
Why do you need a super large int anyway? Usually an unsigned long or double will be plenty for any real-world applications.
**EDIT**
long int is the same as int, for most cases.
>>then long long....
I don't think that's a standard type, although the Windows API has a LONG_LONG struct or something that it uses in some of its more precision-demanding functions.
no, you cant make a variable go up to infinity. An integer size is defined by your compiler, and you cant change its size. If you are using windows, you can use the LARGE_INTEGER type which is 64 bits wide. This doesn't reach infinity, but it gets pretty high :)
no reason yet. I just want a big number. Becuase when you multiply 2 big numbers you get a small. And does long long long long int really work?
>>does long long long long int really work?
We all wish it did. ;)
>>Becuase when you multiply 2 big numbers you get a small.
Generally you don't run into this problem unless dealing with crazy math formulas. Even then, if you don't mind losing precision then you can round/truncate it to 5+ significant figures or so and then use scientific notation (doubles do this I think). Even the number of milliseconds a computer has been running can be stored in an unsigned long for several years running.
no, it doesn't.Quote:
And does long long long long int really work?
Perhaps it isn't at that. He is after all speaking of C++. However in C that is a valid data type. It is intended to support 64 bit integers now that 64 bit processors are coming. for unsigned long its minimun range isQuote:
I don't think that's a standard type, although the Windows API has a LONG_LONG struct or something that it uses in some of its more precision-demanding functions.
for unsigned long long it is 18 quintillion, four hundred and forty-six quadrillion,seven hundred forty-four trillion,seventy three billion,seven hundred nine million, five hundred fifty-one thousand, six hundred and fifteen.Code:0 to 4,294,967,295
thats in u.s. notation. :p
lol you hit the spot. I am making a computer program to help me and others do math probeblems. And once I take algebra I might get those crazy math probebelems for extra credit or somtin.
I'll have to try that out, I've never heard of long long's before... only doubles.
doubles come a little after. Then if your man enough you can hit long doubles. but C only gurantees its percision is at least as percise as double :DQuote:
Originally Posted by Hunter2
>I've never heard of long long's before... only doubles.
long long is an extension except in C99. The largest possible standard built-in type in C++ is long double.
so basicly the longest thing I can get is a long double int?
>>Then if your man enough you can hit long doubles.
long doubles... 16 bytes/128 bits?
>>but C only gurantees its percision is at least as percise as double
Precision as in significant figures as opposed to magnitude? That would mean... 8 bytes to hold the sign bit and exponent. And if you consider it, that means the exponent can go up to "18 quintillion, four hundred and forty-six quadrillion,seven hundred forty-four trillion,seventy three billion,seven hundred nine million, five hundred fifty-one thousand, six hundred and fifteen"? :p
I think you leave out the int part. Though I believe technically you can leave it in. is that right prelude?Quote:
Originally Posted by Rune Hunter