Peter wrote regarding 'Re: [EE] Big numbers' on Thu, Apr 20 at 14:05: > > On Thu, 20 Apr 2006, YAP wrote: > > > What is 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF (128 bits) in decimal? How go a > > head an calculate big numbers like this. > > plp@plp:~$ bc -l > bc 1.06 Somewhat interestingly, this led me to find that perl apparently can't cope with hex numbers greater than 32 bits on my 32-bit processor, even with the bignum module loaded... [danny@random-machine]$ perl -Mbignum -le'print hex("F"x8)' 4294967295 [danny@random-machine]$ perl -Mbignum -le'print hex("F"x9)' Integer overflow in hexadecimal number at -e line 1. 68719476735 [danny@random-machine]$ perl -Mbignum -le'print hex("F"x32)' Integer overflow in hexadecimal number at -e line 1. 3.40282366920938e+38 And printf sucks [danny@random-machine]$ perl -e'printf "%d\n", 0xFFFFFFFFFFFFFFFF' Integer overflow in hexadecimal number at -e line 1. -1 But it works fine with the same non-hex numbers... [danny@random-machine]$ perl -le'print 2**128 - 1' 3.40282366920938e+38 [danny@random-machine]$ perl -Mbignum -le'print 2**128 - 1' 340282366920938463463374607431768211455 And, BTW, you can pipe math into bc - which is something I used somewhat regularly... [danny@random-machine]$ echo "(2^128)-1" | bc 340282366920938463463374607431768211455 Anyway, it was interesting to me, so I figured at least one other person might agree. :) --Danny, obviously just killing time -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist