Generate Random Number With Specific Data Type
Hello,
I'm new in c++, and I have question regarding generate random number with a really long integer.
First, I tried like this :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
int main()
{
srand(time(0));
unsigned long long randomNumber1 = rand();
unsigned long long randomNumber2 = rand();
unsigned long long num1 = (randomNumber1 % 8999999999999999999);
unsigned long long num2 = (randomNumber2 % 8999999999999999999);
cout<<"1st random number = " << num1 << endl;
cout<<"2nd random number = " << num2 << endl;
return 0;
}
|
it works fine, but I can not make it exceed 8999999999999999999.
my idea would be to define new data type that is 224 bit integer.
So my questions are :
1. how to define new 224 bit integer?
2. how to generate random number using that new data type?
Thank you.
Topic archived. No new replies allowed.