instance methods
|
Arithmetic operations
|
|
|
Performs various arithmetic operations on big.
big
|
+ |
aNumeric
|
Addition |
big
|
-- |
aNumeric
|
Subtraction |
big
|
* |
aNumeric
|
Multiplication |
big
|
/ |
aNumeric
|
Division |
big
|
% |
aNumeric
|
Modulo |
big
|
** |
aNumeric
|
Exponentiation |
|
Bit operations
|
|
|
Performs various operations on the binary
representations of the Bignum .
~ big
|
Invert bits |
big
|
| |
aNumeric
|
Bitwise OR
|
big
|
& |
aNumeric
|
Bitwise AND
|
big
|
^ |
aNumeric
|
Bitwise EXCLUSIVE OR
|
big
|
<< |
aNumeric
|
Left-shift aNumeric bits |
big
|
>> |
aNumeric
|
Right-shift aNumeric bits
(with sign extension) |
|
<=>
|
big <=> aNumeric -> -1, 0, +1
|
|
Comparison---Returns -1, 0, or +1 depending on
whether big is less
than, equal to, or greater than aNumeric. This is the
basis for the tests in Comparable .
|
[ ]
|
big[ n ] -> 0, 1
|
|
Bit Reference---Returns the nth bit in
the (assumed) binary representation of big,
where big[0] is the least significant bit.
a = 9**15
50.downto(0) do |n|
print a[n]
end
|
produces:
000101110110100000111000011110010100111100010111001
|
|
size
|
big.size -> anInteger
|
|
Returns the number of bytes in the machine representation
of big.
(256**10 - 1).size
|
» |
12
|
(256**20 - 1).size
|
» |
20
|
(256**40 - 1).size
|
» |
40
|
|
to_f
|
big.to_f -> aFloat
|
|
Converts big to a Float . If big doesn't fit in a
Float , the result is infinity.
|
to_i
|
big.to_i ->
big
|
|
Returns big.
|
to_s
|
big.to_s -> aString
|
|
Returns a string containing the decimal representation of big.
|