Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Integer#size

() -> ::Integer
size → integer

Returns the number of bytes in the machine representation of self; the value is system-dependent:

Example
1.size             # => 8
-1.size            # => 8
2147483647.size    # => 8
(256**10 - 1).size # => 10
(256**20 - 1).size # => 20
(256**40 - 1).size # => 40
See also #round #succ #remainder #times also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0