119件ヒット
[1-100件を表示]
(0.082秒)
種類
- インスタンスメソッド (74)
- 特異メソッド (33)
- 文書 (12)
ライブラリ
- ビルトイン (74)
- bigdecimal (33)
クラス
- BigDecimal (33)
- Float (19)
- Rational (55)
キーワード
-
NEWS for Ruby 2
. 5 . 0 (7) -
NEWS for Ruby 2
. 7 . 0 (5) - floor (11)
- limit (11)
- mode (22)
- round (30)
-
to
_ i (11) - truncate (11)
検索結果
先頭5件
-
Rational
# ceil(precision = 0) -> Integer | Rational (18273.0) -
自身と等しいかより大きな整数のうち最小のものを返します。
...ます。
@param precision 計算結果の精度
@raise TypeError precision に整数以外のものを指定すると発生します。
//emlist[例][ruby]{
Rational(3).ceil # => 3
Rational(2, 3).ceil # => 1
Rational(-3, 2).ceil # => -1
//}
precision を指定した場合は指定した......Rational を返します。
//emlist[例][ruby]{
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... -
NEWS for Ruby 2
. 7 . 0 (372.0) -
NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...は参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリストは ChangeLog ファイルか bugs.ruby-lang.org の issue を参照してください。
== 2.6.0 以降の変更
=== 言語仕様の変更
==== パターンマッチ
* パターンマ......出ます。
この警告は「-W:no-deprecated」オプションで止められます。
* ヒアドキュメントの識別子の引用符は同じ行で閉じる必要があります。
//emlist{
<<"EOS
" # This had been warned since 2.4; Now it raises a SyntaxError
EOS
//}
* フリッ......* 新規メソッド
* Symbol#start_with?とSymbol#end_with?が追加されました。 16348
* Time
* 新規メソッド
* Time#ceilが追加されました。 15772
* Time#floorが追加されました。 15653
* 変更されたメソッド
* Time#inspectがTime#... -
Rational
# floor(precision = 0) -> Integer | Rational (148.0) -
自身と等しいかより小さな整数のうち最大のものを返します。
...ます。
@param precision 計算結果の精度
@raise TypeError precision に整数以外のものを指定すると発生します。
//emlist[例][ruby]{
Rational(3).floor # => 3
Rational(2, 3).floor # => 0
Rational(-3, 2).floor # => -2
//}
Rational#to_i とは違う結果を返す事......1
Rational(-7, 4).to_i # => -1
Rational(-7, 4).floor # => -2
//}
precision を指定した場合は指定した桁数の数値と、上述の性質に最も近い整
数か Rational を返します。
//emlist[例][ruby]{
Rational('-123.456').floor(+1) # => (-247/2)
Rational('-123.456').fl......oor(+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 (148.0) -
自身ともっとも近い整数を返します。
....5, -0.5 はそれぞれ 1,-1 に切り上げされます。
@param precision 計算結果の精度
@raise TypeError precision に整数以外のものを指定すると発生します。
//emlist[例][ruby]{
Rational(3).round # => 3
Rational(2, 3).round # => 1
Rational(-3, 2).round # => -2......ist[例][ruby]{
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, Rationa... -
BigDecimal
. mode(s) -> Integer | nil (142.0) -
BigDecimal の計算処理の制御方法を設定、確認します。
...が有効になり、false を指定した場合
は設定値が無効になります。
@raise TypeError 引数 s に有効でない値を指定した場合に発生します。
@raise ArgumentError 引数 s に例外処理に関する値を指定し、引数 v に
t......cimal::EXCEPTION_INFINITY のとき、無限(+ or -Infinity)
* BigDecimal::EXCEPTION_UNDERFLOW のとき、ゼロ
* BigDecimal::EXCEPTION_OVERFLOW のとき、+Infinity か -Infinity
* BigDecimal::EXCEPTION_ZERODIVIDE のとき、+Infinity か -Infinity
BigDecimal::EXCEPTION_INFINITY、BigDec......六入します。5の時は上位1桁が奇数の時のみ繰り上げます(Banker's rounding)。
* BigDecimal::ROUND_CEILING 数値の大きい方に繰り上げます(ceil)。
* BigDecimal::ROUND_FLOOR 数値の小さい方に繰り下げます(floor)。
戻り値は指定後の flag の値... -
BigDecimal
. mode(s , v) -> Integer | nil (142.0) -
BigDecimal の計算処理の制御方法を設定、確認します。
...が有効になり、false を指定した場合
は設定値が無効になります。
@raise TypeError 引数 s に有効でない値を指定した場合に発生します。
@raise ArgumentError 引数 s に例外処理に関する値を指定し、引数 v に
t......cimal::EXCEPTION_INFINITY のとき、無限(+ or -Infinity)
* BigDecimal::EXCEPTION_UNDERFLOW のとき、ゼロ
* BigDecimal::EXCEPTION_OVERFLOW のとき、+Infinity か -Infinity
* BigDecimal::EXCEPTION_ZERODIVIDE のとき、+Infinity か -Infinity
BigDecimal::EXCEPTION_INFINITY、BigDec......六入します。5の時は上位1桁が奇数の時のみ繰り上げます(Banker's rounding)。
* BigDecimal::ROUND_CEILING 数値の大きい方に繰り上げます(ceil)。
* BigDecimal::ROUND_FLOOR 数値の小さい方に繰り下げます(floor)。
戻り値は指定後の flag の値... -
Rational
# to _ i -> Integer (136.0) -
小数点以下を切り捨てて値を整数に変換します。
...算結果の精度
@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... -
Rational
# truncate(precision = 0) -> Rational | Integer (136.0) -
小数点以下を切り捨てて値を整数に変換します。
...算結果の精度
@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... -
Float
# round(ndigits = 0) -> Integer | Float (130.0) -
自身ともっとも近い整数もしくは実数を返します。
...自身ともっとも近い整数もしくは実数を返します。
中央値 0.5, -0.5 はそれぞれ 1,-1 に切り上げされます。
いわゆる四捨五入ですが、偶数丸めではありません。
@param ndigits 丸める位を指定します。
ndigitsが0ならば、小......整数を返します。
@raise TypeError ndigits で指定されたオブジェクトが整数に変換できない場
合発生します。
//emlist[例][ruby]{
1.0.round # => 1
1.2.round # => 1
(-1.2).round # => -1
(-1.5).round # => -2
t = Math::PI # => 3.1415926......53589793
t.round(3) # => 3.142
t.round(0) # => 3
t.round(1) # => 3.1
t = t**10 # => 93648.04747608298
t.round(-0) # => 93648
t.round(-1) # => 93650
t.round(-2) # => 93600
t.round(-3) # => 94000
t.round(-100) # => 0
//}
@see Float#ceil, Float#floor, Float#truncate......und(-1) # => 93650
t.round(-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, F... -
Float
# round(ndigits = 0 , half: :up) -> Integer | Float (130.0) -
自身ともっとも近い整数もしくは実数を返します。
...自身ともっとも近い整数もしくは実数を返します。
中央値 0.5, -0.5 はそれぞれ 1,-1 に切り上げされます。
いわゆる四捨五入ですが、偶数丸めではありません。
@param ndigits 丸める位を指定します。
ndigitsが0ならば、小......整数を返します。
@raise TypeError ndigits で指定されたオブジェクトが整数に変換できない場
合発生します。
//emlist[例][ruby]{
1.0.round # => 1
1.2.round # => 1
(-1.2).round # => -1
(-1.5).round # => -2
t = Math::PI # => 3.1415926......und(-1) # => 93650
t.round(-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, F...