October 2006
Intermediate to advanced
888 pages
16h 55m
English
The control of large numbers is possible, and like unto that of small numbers, if we subdivide them.
—Sun Tze
In the event it becomes necessary, Ruby programmers can work with integers of arbitrary size. The transition from a Fixnum to a Bignum is handled automatically and transparently. In this following piece of code, notice how a result that is large enough is promoted from Fixnum to Bignum:
num1 = 1000000 # One million (10**6) num2 = num1*num1 # One trillion (10**12) puts num1 # 1000000 puts num1.class # Fixnum puts num2 # 1000000000000 puts num2.class # Bignum
The size of a Fixnum varies from one architecture to another. Calculations with Bignums are limited only by memory and processor speed. They ...
Read now
Unlock full access