るりまサーチ (Ruby 2.6.0)

最速Rubyリファレンスマニュアル検索!
4件ヒット [1-4件を表示] (0.031秒)
トップページ > バージョン:2.6.0[x] > クエリ:nil[x] > クラス:Float[x]

別のキーワード

  1. _builtin nil?
  2. object nil?
  3. nilclass nil?
  4. object nil
  5. _builtin nil

ライブラリ

キーワード

検索結果

Float#<=>(other) -> -1 | 0 | 1 | nil (391.0)

self と other を比較して、self が大きい時に正、 等しい時に 0、小さい時に負の整数を返します。 比較できない場合はnilを返します

self と other を比較して、self が大きい時に正、
等しい時に 0、小さい時に負の整数を返します。
比較できない場合はnilを返します

//emlist[例][ruby]{
3.05 <=> 3.14 # => -1
1.732 <=> 1.414 # => 1
3.3 - 3.3 <=> 0.0 # => 0
3.14 <=> "hoge" # => nil
3.14 <=> 0.0/0.0 # => nil
//}

Float#infinite? -> 1 | -1 | nil (355.0)

数値が +∞ のとき 1、-∞のとき -1 を返します。それ以外は nil を返 します。

数値が +∞ のとき 1、-∞のとき -1 を返します。それ以外は nil を返
します。

//emlist[例][ruby]{
inf = 1.0/0
p inf # => Infinity
p inf.infinite? # => 1

inf = -1.0/0
p inf # => -Infinity
p inf.infinite? # => -1
//}

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

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

...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 (22.0)

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

...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...