This is a Ruby tree! It shows every object from the Ruby Programming Language in a tree format.
# Float.round (from ruby core) --- round(ndigits = 0, half: :up]) -> integer or float --- Returns `self` rounded to the nearest value with a precision of `ndigits` decimal digits. When `ndigits` is non-negative, returns a float with `ndigits` after the decimal point (as available): f = 12345.6789 f.round(1) # => 12345.7 f.round(3) # => 12345.679 f = -12345.6789 f.round(1) # => -12345.7 f.round(3) # => -12345.679 When `ndigits` is negative, returns an integer with at least `ndigits.abs` trailing zeros: f = 12345.6789 f.round(0) # => 12346 f.round(-3) # => 12000 f = -12345.6789 f.round(0) # => -12346 f.round(-3) # => -12000 If keyword argument `half` is given, and `self` is equidistant from the two candidate values, the rounding is according to the given `half` value: * `:up` or `nil`: round away from zero: 2.5.round(half: :up) # => 3 3.5.round(half: :up) # => 4 (-2.5).round(half: :up) # => -3 * `:down`: round toward zero: 2.5.round(half: :down) # => 2 3.5.round(half: :down) # => 3 (-2.5).round(half: :down) # => -2 * `:even`: round toward the candidate whose last nonzero digit is even: 2.5.round(half: :even) # => 2 3.5.round(half: :even) # => 4 (-2.5).round(half: :even) # => -2 Raises and exception if the value for `half` is invalid. Related: Float#truncate.
This is MURDOC! A Ruby documentation browser inspired by Smalltalk-80. It allows you to learn about Ruby by browsing through its class hierarchies, and see any of its methods.