1. Is there a way in Ruby to speed up 32bit integer arithmetics (only
involving numbers & sums up to 2^32-1)? I want to use Ruby for
summarizing network traffic logs, but it's pathetically slow compared to
Perl:
$ time ruby -e'1000000.times{1073741823+1073741824}'
real 0m23.693s
user 0m5.720s
sys 0m0.610s
$ time perl -e'for(1..1000000){1073741823+1073741824}'
real 0m1.142s
user 0m0.320s
sys 0m0.050s
since 2**30 is already in the Bignum range.
2. Doing arbitrary integer math is already very convenient in Ruby
because of its automatic conversion. But Ruby still doesn't do seamless
conversion to arbitrary floating point numbers:
$ irb
irb(main):001:0> 0.00000000000000001
=> 1.0e-17
irb(main):002:0> 0.000000000000000001
=> 0.0
Any chance Ruby will do this in the future? Or perhaps in the nearer
future, include an arbitrary floating number package in its distribution
(is there any? GMP is GPL so it potentially a problem license-wise).
--
dave