Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Float#magnitude
() -> ::Float
magnitude
numeric.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.4.1/numeric.rb, line 368
def abs
Primitive.attr! :leaf
Primitive.cexpr! 'rb_float_abs(self)'
end
Alias of #abs
Returns the absolute value of self:
Example
(-34.56).abs # => 34.56 -34.56.abs # => 34.56 34.56.abs # => 34.56