るりまサーチ

最速Rubyリファレンスマニュアル検索!
232件ヒット [201-232件を表示] (0.010秒)

別のキーワード

  1. _builtin truncate
  2. bigdecimal truncate
  3. csv truncate
  4. file truncate
  5. stringio truncate

ライブラリ

クラス

キーワード

検索結果

<< < 1 2 3 >>

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

自身と等しいかより小さな整数のうち最大のものを返します。

...onal を返します。

//emlist[例][ruby]{
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#round(precision = 0) -> Integer | Rational (12.0)

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

...y]{
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...

bigdecimal (12.0)

bigdecimal は浮動小数点数演算ライブラリです。 任意の精度で 10 進表現された浮動小数点数を扱えます。

...定できます。

//emlist[][ruby]{
require "bigdecimal"
p BigDecimal("2").div(3, 12).to_s(10) # 2.0 / 3.0
# => 0.6666666666 67e0
//}

: truncate, round, ceil, floor

これらのメソッドは小数点からの相対位置を指定して桁数を決定します。

//emlist[][ruby]{
require "b...
<< < 1 2 3 >>