Sign up ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

If I create an array with 10 random numbers in the range [0, 2^30]. How can calculate the number of bits that it will consume of memory?

Let's assume that each of the numbers has 10 digits. That totals 100 digits. Would it be 800 bits (8 bits per character)?

share|cite|improve this question
This question would probably be better suited for, but usually you declare an array of a certain datatype, so here you would probably have an array of 32 bit integers (doubles) so it would occupy 320 bits unless your language dynamically allocates memory based on the items in your array in which case this turns into an expected value problem... –  Jeremy Oct 26 '12 at 5:23

1 Answer 1

up vote 0 down vote accepted

If they are randomly distributed, each one needs 30 bits, so you need 300 bits if you store them in binary. If you convert them to decimal, you need 10 digits each (maybe 11). Then if you store the digits in 8 bit ASCII you need 800 (or 880) bits. The big inefficiency is taking a decimal digit (of which there are only 10) and using 8 bits (of which there are 256) to store it.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.