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

## 検索結果

### Rational#to_i -> Integer (18132.0)

...例:

Rational
(2, 3).to_i # => 0
Rational
(3).to_i # => 3
Rational
(300.6).to_i # => 300
Rational
(98, 71).to_i # => 1
Rational
(-30, 2).to_i # => -15

precision を指定した場合は指定した桁数で切り捨てた整数か
Rational
を返します。

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

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

### Rational#truncate(precision = 0) -> Rational | Integer (3032.0)

...例:

Rational
(2, 3).to_i # => 0
Rational
(3).to_i # => 3
Rational
(300.6).to_i # => 300
Rational
(98, 71).to_i # => 1
Rational
(-30, 2).to_i # => -15

precision を指定した場合は指定した桁数で切り捨てた整数か
Rational
を返します。

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

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

### Rational#floor(precision = 0) -> Integer | Rational (19.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...