るりまサーチ

最速Rubyリファレンスマニュアル検索!
19件ヒット [1-19件を表示] (0.026秒)
トップページ > ライブラリ:ビルトイン[x] > クエリ:TypeError[x] > クラス:Float[x]

別のキーワード

  1. _builtin typeerror
  2. sort typeerror
  3. dump typeerror
  4. $@ typeerror
  5. $~ typeerror

検索結果

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

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

...ndigitsが0より大きいならば、実数を返します。
ndigitsが0より小さいならば、整数を返します。

@raise TypeError ndigits で指定されたオブジェクトが整数に変換できない場
合発生します。

//emlist[例][ruby]{
1.0.r...
...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) # => 93600
t.round(-3) # => 94000
t.round(-100) # => 0
//}

@see Float#ceil, Float#floor, Float#truncate...
...d(-2) # => 93600
t.round(-3) # => 94000
t.round(-100) # => 0

2.5.round(half: :up) # => 3
2.5.round(half: :even) # => 2
2.5.round(half: :down) # => 2
3.5.round(half: :up) # => 4
3.5.round(half: :even) # => 4
3.5.round(half: :down) # => 3
//}

@see Float#ceil, Float#floor, Float#truncate...

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

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

...ndigitsが0より大きいならば、実数を返します。
ndigitsが0より小さいならば、整数を返します。

@raise TypeError ndigits で指定されたオブジェクトが整数に変換できない場
合発生します。

//emlist[例][ruby]{
1.0.r...
...d(-2) # => 93600
t.round(-3) # => 94000
t.round(-100) # => 0

2.5.round(half: :up) # => 3
2.5.round(half: :even) # => 2
2.5.round(half: :down) # => 2
3.5.round(half: :up) # => 4
3.5.round(half: :even) # => 4
3.5.round(half: :down) # => 3
//}

@see Float#ceil, Float#floor, Float#truncate...