るりまサーチ (Ruby 3.1)

最速Rubyリファレンスマニュアル検索!
2件ヒット [1-2件を表示] (0.037秒)
トップページ > ライブラリ:ビルトイン[x] > クエリ:_builtin[x] > クエリ:float[x] > クエリ:at[x] > クエリ:*[x] > バージョン:3.1[x] > クエリ:round[x]

別のキーワード

  1. _builtin float
  2. float to_d
  3. json float
  4. float rationalize
  5. fiddle type_float

クラス

検索結果

Float#round(ndigits = 0) -> Integer | Float (115351.0)

自身ともっとも近い整数もしくは実数を返します。

...1.0.round # => 1
1.2.round # => 1
(-1.2).round # => -1
(-1.5).round # => -2

t = Math::PI # => 3.141592653589793
t.round(3) # => 3.142
t.round(0) # => 3
t.round(1) # => 3.1

t = t**10 # => 93648.04747608298
t.round(-0) # => 93648
t.round(-1) # => 93650
t.round(-2) #...

Float#round(ndigits = 0, half: :up) -> Integer | Float (115351.0)

自身ともっとも近い整数もしくは実数を返します。

...1.0.round # => 1
1.2.round # => 1
(-1.2).round # => -1
(-1.5).round # => -2

t = Math::PI # => 3.141592653589793
t.round(3) # => 3.142
t.round(0) # => 3
t.round(1) # => 3.1

t = t**10 # => 93648.04747608298
t.round(-0) # => 93648
t.round(-1) # => 93650
t.round(-2) #...