# How Many Digits Can __int64 Store?

## Recommended Posts

Does anyone know the highest number that the __int64 variable can store?

And, in the event that you were to try to display a bunch of 0's... in this case, more then the estimated amount of known sub-atomic particles in the universe... what would happen?

##### Share on other sites

a) 2^64 = 18,446,744,073,709,551,616 is the biggest number 64 bits could hold (possibly 18,446,744,073,709,551,616 - 1?)... and that's *counts with fingers* 20 digits...

b) Don't know Try it!!! DO IT!!!!!

EDIT:

Wey hey hey!

```#include <stdio.h>

int main(void) {
unsigned __int64 counter, max;

memset(&max, 0xff, sizeof(__int64));
printf("Maximum number: %20.0I64u\n", max);
system("pause");

for (counter = 0; counter < max; counter++) {
printf("Current number: %20.0I64u\n", counter);
}

system("pause");
}
```

Tis a mighty long loop.......... and 64 bit numbers seem to be a bit problematic with printf() and different O/S's and stuff, so the above might only work with Dev-C++ and Windows

##### Share on other sites

Give me a few seconds...

*several minutes later*

```#include <iostream>

using namespace std;

__int64 firstNumber = 18,000,000,000,000,000,000;
__int64 secondNumber = 18,000,000,000,000,000,000;
__int64 thirdNumber = 18,000,000,000,000,000,000;
__int64 fourthNumber = 18,000,000,000,000,000,000;
__int64 fithNumber = 18,000,000,000,000,000,000;
__int64 sixthNumber = 18,000,000,000,000,000,000;

__int64 i;

int main() {

for(i=0,i<=firstNumber,i++) {
cout << "0\n";
system("cls");
}

for(i=0,i<=secondNumber,i++) {
cout << "0\n";
system("cls");
}

for(i=0,i<=thirdNumber,i++) {
cout << "0\n";
system("cls");
}

for(i=0,i<=fourthNumber,i++) {

cout << "0\n";
system("cls");
}

for(i=0,i<=fithNumber,i++) {

cout << "0\n";
system("cls");

}

for(i=0,i<=sixthNumber,i++) {

cout << "0\n";
system("cls");

}

system("pause");

return 0;

}```

A little messy, yesh... but... you can try it first .

##### Share on other sites
Give me a few seconds...

*several minutes later*

```#include <iostream>

using namespace std;

__int64 firstNumber = 18,000,000,000,000,000,000;
__int64 secondNumber = 18,000,000,000,000,000,000;
__int64 thirdNumber = 18,000,000,000,000,000,000;
__int64 fourthNumber = 18,000,000,000,000,000,000;
__int64 fithNumber = 18,000,000,000,000,000,000;
__int64 sixthNumber = 18,000,000,000,000,000,000;

__int64 i;

int main() {

for(i=0,i<=firstNumber,i++) {
cout << "0\n";
system("cls");
}

for(i=0,i<=secondNumber,i++) {
cout << "0\n";
system("cls");
}

for(i=0,i<=thirdNumber,i++) {
cout << "0\n";
system("cls");
}

for(i=0,i<=fourthNumber,i++) {

cout << "0\n";
system("cls");
}

for(i=0,i<=fithNumber,i++) {

cout << "0\n";
system("cls");

}

for(i=0,i<=sixthNumber,i++) {

cout << "0\n";
system("cls");

}

system("pause");

return 0;

}```

A little messy, yesh... but... you can try it first .

537072[/snapback]

lol. Just a couple of things (one of which I only just found out myself!!)..

a) for loops seperated by ; not ,

for(i=0,i<=sixthNumber,i++)

b) numbers... no ,'s at all

__int64 firstNumber = 18,000,000,000,000,000,000;

c) All those big numbers should probably be unsigned too

unsigned __int64 firstNumber = 18000000000000000000;

d) Apparently for big numbers you need a suffix, ULL (for "unsigned long long", because that's what "unsigned __int64" really is), at the end of the number! Otherwise the compiler complains! There's also just a single L to indicate a "long" number... so I learnt something new

unsigned __int64 firstNumber = 18000000000000000000ULL;

I seem to remember there being F for floating points numbers of something... maybe a little f? So like 0.14f .... but I never actually used that little convention before because it didn't seem to make any difference!

http://64.233.183.104/search?q=cache:Dd_bd...g%22+type&hl=en

As for improvements to your program, since all those numbers were the same value you could have done it with two for loops

```#include <iostream>

unsigned __int64 firstNumber = 18000000000000000000ULL;
int times = 6, i;
unsigned __int64 j;

using namespace std;

int main(void) {
for (i = 0; i < times; i++) {
for(j = 0; j <= firstNumber; j++) {
cout << "0\n";
system("cls");
}
}

system("pause");
return 0;
}
```

##### Share on other sites

Now, to try it without the system("cls")...

You go first .

##### Share on other sites
ok!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :thumbs-up: (yes, I am awake!)

##### Share on other sites

Yay, he's awake and willing to attempt the physically impossible!

*turns on music*

##### Share on other sites
Yay, he's awake and willing to attempt the physically impossible!

*turns on music*

538372[/snapback]

haha! i actually went back to sleep after I posted that :thumbs-up:

GPU-Z Sensor Log 5.txt

*play popeye the sailor man on harmonica* yes, yes, I know! I rule!!!

##### Share on other sites

*plays the low brass accompaniment*

Think it'll get done after school?

##### Share on other sites

lol probly not, cause i'm likely not going to be here again later! oh noes!!!1111111

Gasp, you lies!