Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Integer#size
() -> ::Integer
size → integer
numeric.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/numeric.rb, line 239
def size
Primitive.attr! :leaf
Primitive.cexpr! 'rb_int_size(self)'
end
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