array of 32bit container
-
Good afternoon
I am new in c++. I am trying to write a code that uses an array of 2 exponent 32, A small example is the code below.
#include # include # include # include # include #include # include #include #include #include #include #define two_power(n) (1u << (n))
using namespace std;typedef unsigned long word32;
int main()
{
word32 delta, alfa;
static word32 array[4294967295][4294967295] ={0};
for (delta = 0; delta < 4294967296; delta++)
{
for (alfa = 0; alfa < 4294967296; alfa++)
{
array[delta][alfa] = alfa + delta;
}
}
cout << array[4294967295][4294967295];
return 0;
}I there any method I can use to instead of using array because arrays have limitation in size. 2^32 = 4294967296. You can send me an email if you have an answer
-
Good afternoon
I am new in c++. I am trying to write a code that uses an array of 2 exponent 32, A small example is the code below.
#include # include # include # include # include #include # include #include #include #include #include #define two_power(n) (1u << (n))
using namespace std;typedef unsigned long word32;
int main()
{
word32 delta, alfa;
static word32 array[4294967295][4294967295] ={0};
for (delta = 0; delta < 4294967296; delta++)
{
for (alfa = 0; alfa < 4294967296; alfa++)
{
array[delta][alfa] = alfa + delta;
}
}
cout << array[4294967295][4294967295];
return 0;
}I there any method I can use to instead of using array because arrays have limitation in size. 2^32 = 4294967296. You can send me an email if you have an answer
That is just crazy, you are trying to reserve 73,786,976,294,838,206,464 bytes in your program. And given that all your program does (or tries to do) is print the numbers from 1 to that value, it is rather a waste of time. You can use a single variable and write a loop that increments it from 1 to whatever final value you want, printing each value as it goes round the loop. You also do not need most of those
#include
statements; only include the ones you need. -
Good afternoon
I am new in c++. I am trying to write a code that uses an array of 2 exponent 32, A small example is the code below.
#include # include # include # include # include #include # include #include #include #include #include #define two_power(n) (1u << (n))
using namespace std;typedef unsigned long word32;
int main()
{
word32 delta, alfa;
static word32 array[4294967295][4294967295] ={0};
for (delta = 0; delta < 4294967296; delta++)
{
for (alfa = 0; alfa < 4294967296; alfa++)
{
array[delta][alfa] = alfa + delta;
}
}
cout << array[4294967295][4294967295];
return 0;
}I there any method I can use to instead of using array because arrays have limitation in size. 2^32 = 4294967296. You can send me an email if you have an answer
So you need 73.78 x 10^18 bytes? Wow! May I ask what you're using it for? Generally I'd use a vector instead of arrays and let the vector handle the memory allocations/deallocations, but I've never had to deal with numbers that large. I can't imagine your code being able to allocate that kind of space. The program you've posted is accessing an invalid array index, the largest index you can theoretically have is array[4294967294][4294967294], because there are 4294967295 entries in each dimension, entries 0-4294967294.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
-
So you need 73.78 x 10^18 bytes? Wow! May I ask what you're using it for? Generally I'd use a vector instead of arrays and let the vector handle the memory allocations/deallocations, but I've never had to deal with numbers that large. I can't imagine your code being able to allocate that kind of space. The program you've posted is accessing an invalid array index, the largest index you can theoretically have is array[4294967294][4294967294], because there are 4294967295 entries in each dimension, entries 0-4294967294.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
jeron1 wrote:
because there are 4294967295 entries in each dimension
Yes but he's writing his program in the fourth dimension!
The difficult we do right away... ...the impossible takes slightly longer.
-
jeron1 wrote:
because there are 4294967295 entries in each dimension
Yes but he's writing his program in the fourth dimension!
The difficult we do right away... ...the impossible takes slightly longer.
Because in the fourth dimension no one can hear your allocation fail? :)
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
-
Because in the fourth dimension no one can hear your allocation fail? :)
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
What does my question has to deal with facebook and drinking behaviour?
-
jeron1 wrote:
because there are 4294967295 entries in each dimension
Yes but he's writing his program in the fourth dimension!
The difficult we do right away... ...the impossible takes slightly longer.
So what is it that has to be done. I want to create Differential Distribution Table (DDT) of Blowfish algorithm. I have done for DES.
-
So you need 73.78 x 10^18 bytes? Wow! May I ask what you're using it for? Generally I'd use a vector instead of arrays and let the vector handle the memory allocations/deallocations, but I've never had to deal with numbers that large. I can't imagine your code being able to allocate that kind of space. The program you've posted is accessing an invalid array index, the largest index you can theoretically have is array[4294967294][4294967294], because there are 4294967295 entries in each dimension, entries 0-4294967294.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
for Differential Distribution Table of Blowfish algorithm
-
What does my question has to deal with facebook and drinking behaviour?
Member 14812342 wrote:
What does my question has to deal with facebook and drinking behaviour?
Nothing. It was not an answer, just a signature! :laugh:
-
for Differential Distribution Table of Blowfish algorithm