Hacker, author, trainer
Technorati Profile [technorati.com]
This was brought up in a discussion at work today. Spot the odd one out.
(Oracle)
SQL> select BITAND(1798729892926983663,268435455) from dual;
BITAND(1798729892926983663,268435455)
-------------------------------- -----
181013999
$ python
>>> 1798729892926983663 & 268435455
181013999
$ ruby
print 1798729892926983663 & 268435455
181013999
$ perl -le 'print 1798729892926983663 & 268435455'
268435455
Of course, you can always use:
$ perl -Mbignum -le 'print 1798729892926983663 & 268435455'
181013999
But it's a bit embarassing that it doesn't Just Work.
Agreed... (Score:1)
Re: (Score:2)
Re: (Score:1)
Ruby borrowed an idea from Smalltalk. Small integers are of type Fixnum, and it automatically promotes results above about a billion to Bignum on the fly. (IIRC, it has to reserve one bit for the sign and one for some internal bookkeeping.) As a result integer operations with Ruby are always exact. There is some overhead for this scheme, but there are tricks that make it less than you think. (Again, these tricks were worked out for Smalltalk.)
Given that Python
Hmm (Score:2)
Who needs bignums? (Score:1)
Of course, I cheat a little ...
DEC Alpha was born 64bit pure, so Debian installs Perl 64bit on Alpha.
Bill
# I had a sig when sigs were cool
use Sig;