• Create Account

### #ActualCornstalks

Posted 07 February 2013 - 09:10 AM

Is there a way to make this number larger using the "int" besides "long int"

To answer your question: no. If you write 4294967295 in binary it's: 0b11111111111111111111111111111111. There are 32 ones in that binary number. It needs 32 bits, all of them, to represent that number. If you try to go higher, even by one, you need more bits. 32 won't be enough anymore. You can't magically pull more bits out of thin air. You get more bits by either using a larger data type or a custom big integer library (like Milcho said), but it isn't possible to magically add more bits to your int.

If you want to know just how big a number a datatype can hold, you can either google your compiler's documentation, or you can use std::numeric_limits:

#include <iostream>
#include <limits>

int main()
{
std::cout << std::numeric_limits<int>::max() << std::endl; // this will tell you the max for int... it is the *max*... ints *cannot* got higher than this
std::cout << std::numeric_limits<unsigned int>::max() << std::endl; // like above, but for unsigned ints.
}


### #1Cornstalks

Posted 07 February 2013 - 09:06 AM

Is there a way to make this number larger using the "int" besides "long int"

To answer your question: no. If you write 4294967295 in binary it's: 0b11111111111111111111111111111111. There are 32 ones in that binary number. It needs 32 bits, all of them, to represent that number. If you try to go higher, even by one, you need more bits. 32 won't be enough anymore. You can't magically pull more bits out of thin air. You get more bits by either using a larger data type or a custom big integer library (like Milcho said), but it isn't possible to magically add more bits to your int.

PARTNERS