Jump to content
Sign in to follow this  
Kamikaze_Badger

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 this post


Link to post
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 :P

Share this post


Link to post
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 :P.

Share this post


Link to post
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 :P.

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 :P

 

__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 this post


Link to post
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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×