21件ヒット [1-21件を表示] （0.020秒）
トップページ > クラス:Rational > :Rational#round

## 検索結果

### Rational#round(precision = 0) -> Integer | Rational (62323.0)

...ます。

Rational
(3).round # => 3
Rational
(2, 3).round # => 1
Rational
(-3, 2).round # => -2

precision を指定した場合は指定した桁数の数値と、上述の性質に最も近い整

Rational
('-123.456').round(+1) # => (-...
...247/2)
Rational('-123.456').round(+1).to_f # => -123.5
Rational
('-123.456').round(0) # => -123
Rational
('-123.456').round(-1) # => -120
Rational
('-123.456').round(-2) # => -100

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

### Rational#floor(precision = 0) -> Integer | Rational (21210.0)

...

Rational
(3).floor # => 3
Rational
(2, 3).floor # => 0
Rational
(-3, 2).floor # => -2

Rational
#to_i とは違う結果を返す事に注意してください。

Rational
(+7, 4).to_i # => 1
Rational
(+7, 4).floor # => 1
Rational
(-7, 4).to_i # => -1
Rational
(-7, 4)....
...数か Rational を返します。

Rational
('-123.456').floor(+1) # => (-247/2)
Rational
('-123.456').floor(+1).to_f # => -123.5
Rational
('-123.456').floor(0) # => -124
Rational
('-123.456').floor(-1) # => -130

@see Rational#ceil, Rational#round, Rational#truncate...

### Rational#ceil(precision = 0) -> Integer | Rational (21180.0)

...発生します。

Rational
(3).ceil # => 3
Rational
(2, 3).ceil # => 1
Rational
(-3, 2).ceil # => -1

precision を指定した場合は指定した桁数の数値と、上述の性質に最も近い整

Rational
('-123.456').ceil(+1)...
...# => (-617/5)
Rational('-123.456').ceil(+1).to_f # => -123.4
Rational
('-123.456').ceil(0) # => -123
Rational
('-123.456').ceil(-1) # => -120

@see Rational#floor, Rational#round, Rational#truncate...