Wednesday, August 16, 2006

The power of two

If you work in IT business then some numbers are very meaningful
if you see them in a memory dump or a code listing. If you know
about bits and bytes and the mathematics behind them then at least
the following series should be well known:

1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 ...

The series for 16 bits is something you could easily remember.
But whats next. Let's write a small(talk) expression to see how the
series continues up to 1000 bits:

(0 to: 1000) collect: [ :each | 2 raisedTo: each ]

Ooops - I didnt know that (2 raisedTo: 1000) is:

10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376

Really? Unbelievable! Next step would be to learn all of them ;)

No comments: