るりまサーチ

最速Rubyリファレンスマニュアル検索!
11件ヒット [1-11件を表示] (0.152秒)
トップページ > 種類:インスタンスメソッド[x] > クエリ:n[x] > クエリ:cat[x] > クラス:Rational[x]

別のキーワード

  1. etc sc_xopen_enh_i18n
  2. rsa n
  3. rsa n=
  4. openssl n
  5. openssl n=

ライブラリ

検索結果

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

小数点以下を切り捨てて値を整数に変換します。

...on 計算結果の精度

@raise TypeError precision に整数以外のものを指定すると発生します。

//emlist[例][ruby]{
Rational
(2, 3).to_i # => 0
Rational
(3).to_i # => 3
Rational
(300.6).to_i # => 300
Rational
(98, 71).to_i # => 1
Rational
(-31, 2).to_i # => -15
//}

precision...
...
Rational
を返します。

//emlist[例][ruby]{
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...