Type:
Class

When mathn is required, Fixnum's division and exponentiation are enhanced to return more precise values from mathematical expressions.

1
2
3
2/3*3  # => 0
require 'mathn'
2/3*3  # => 2

A Fixnum holds Integer values that can be represented in a native machine word (minus 1 bit). If any operation on a Fixnum exceeds this range, the value is automatically converted to a Bignum.

Fixnum objects have immediate value. This means that when they are assigned or passed as parameters, the actual object is passed, rather than a reference to that object. Assignment does not alias Fixnum objects. There is effectively only one Fixnum object instance for any given integer value, so, for example, you cannot add a singleton method to a Fixnum.

*
  • References/Ruby on Rails/Ruby/Classes/Fixnum

fix * numeric â numeric_result Instance Public methods Performs multiplication:

2025-01-10 15:47:30
>=
  • References/Ruby on Rails/Ruby/Classes/Fixnum

fix >= real â true or false Instance Public methods Returns true

2025-01-10 15:47:30
<=>
  • References/Ruby on Rails/Ruby/Classes/Fixnum

fix numeric â -1, 0, +1 or nil Instance Public methods ComparisonâReturns

2025-01-10 15:47:30
divmod
  • References/Ruby on Rails/Ruby/Classes/Fixnum

fix.divmod(numeric) â array Instance Public methods See Numeric#divmod

2025-01-10 15:47:30
to_s
  • References/Ruby on Rails/Ruby/Classes/Fixnum

fix.to_s(base=10) â string Instance Public methods Returns a string containing

2025-01-10 15:47:30
===
  • References/Ruby on Rails/Ruby/Classes/Fixnum

fix == other â true or false Instance Public methods Return true

2025-01-10 15:47:30
==
  • References/Ruby on Rails/Ruby/Classes/Fixnum

fix == other â true or false Instance Public methods Return true

2025-01-10 15:47:30
|
  • References/Ruby on Rails/Ruby/Classes/Fixnum

fix | integer â integer_result Instance Public methods Bitwise OR.

2025-01-10 15:47:30
size
  • References/Ruby on Rails/Ruby/Classes/Fixnum

fix.size â fixnum Instance Public methods Returns the number of bytes

2025-01-10 15:47:30
^
  • References/Ruby on Rails/Ruby/Classes/Fixnum

fix ^ integer â integer_result Instance Public methods Bitwise EXCLUSIVE

2025-01-10 15:47:30