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

- 09-13-2004Rune Huntervaraible help...?
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. - 09-13-2004caroundw5h
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 goCode:`long num`

that's the simple answer. - 09-13-2004Hunter2
>>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. - 09-13-2004bithub
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 :)

- 09-13-2004Rune Hunter
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?

- 09-13-2004Hunter2
>>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. - 09-13-2004bithubQuote:

And does long long long long int really work?

- 09-13-2004caroundw5hQuote:

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.

Code:`0 to 4,294,967,295`

thats in u.s. notation. :p - 09-13-2004Rune Hunter
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.

- 09-13-2004Hunter2
I'll have to try that out, I've never heard of long long's before... only doubles.

- 09-13-2004caroundw5hQuote:

Originally Posted by**Hunter2**

- 09-13-2004Prelude
>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. - 09-13-2004Rune Hunter
so basicly the longest thing I can get is a long double int?

- 09-13-2004Hunter2
>>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 - 09-13-2004caroundw5hQuote:

Originally Posted by**Rune Hunter**