ライブラリ
- ビルトイン (153)
- bigdecimal (48)
- matrix (24)
キーワード
- ceil (42)
- eigen (12)
- eigensystem (12)
- floor (42)
-
save
_ rounding _ mode (12) -
to
_ i (12) - truncate (12)
検索結果
先頭5件
-
Float
# round(ndigits = 0) -> Integer | Float (21311.0) -
自身ともっとも近い整数もしくは実数を返します。
...、小数点以上の指定された位で四捨五入されます。
@param half ちょうど半分の値の丸め方を指定します。
サポートされている値は以下の通りです。
* :up or nil: 0から遠い方に丸められます。
* :even: もっとも近い偶数に......。
//emlist[例][ruby]{
1.0.round # => 1
1.2.round # => 1
(-1.2).round # => -1
(-1.5).round # => -2
t = Math::PI # => 3.141592653589793
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) #......50
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, Float#floor, Float#t... -
Float
# round(ndigits = 0 , half: :up) -> Integer | Float (21311.0) -
自身ともっとも近い整数もしくは実数を返します。
...、小数点以上の指定された位で四捨五入されます。
@param half ちょうど半分の値の丸め方を指定します。
サポートされている値は以下の通りです。
* :up or nil: 0から遠い方に丸められます。
* :even: もっとも近い偶数に......。
//emlist[例][ruby]{
1.0.round # => 1
1.2.round # => 1
(-1.2).round # => -1
(-1.5).round # => -2
t = Math::PI # => 3.141592653589793
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) #......50
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, Float#floor, Float#t... -
BigDecimal
# round(n) -> BigDecimal (21290.0) -
クラスメソッド BigDecimal.mode(BigDecimal::ROUND_MODE,flag) で指定した BigDecimal::ROUND_MODE に従って丸め操作を実行します。
...クラスメソッド BigDecimal.mode(BigDecimal::ROUND_MODE,flag) で指定した
BigDecimal::ROUND_MODE に従って丸め操作を実行します。
@param n 小数点以下の桁数を整数で指定します。
@param b 丸め処理の方式として、BigDecimal.mode の第 1 引数と同じ......gDecimal.mode(BigDecimal::ROUND_MODE,flag) で何も指定せず、
かつ、引数を指定しない場合は
「小数点以下第一位の数を四捨五入して整数(BigDecimal 値)」にします。
//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").round # => 1
BigDecimal("-1.23......//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").round(4).to_f # => 1.2346
BigDecimal("15.23456").round(-1).to_f # => 20.0
//}
2番目の引数を指定すると、BigDecimal.mode の指定を無視して、指定さ
れた方法で丸め操作を実行します。
//emlist[][rub... -
BigDecimal
# round(n , b) -> BigDecimal (21290.0) -
クラスメソッド BigDecimal.mode(BigDecimal::ROUND_MODE,flag) で指定した BigDecimal::ROUND_MODE に従って丸め操作を実行します。
...クラスメソッド BigDecimal.mode(BigDecimal::ROUND_MODE,flag) で指定した
BigDecimal::ROUND_MODE に従って丸め操作を実行します。
@param n 小数点以下の桁数を整数で指定します。
@param b 丸め処理の方式として、BigDecimal.mode の第 1 引数と同じ......gDecimal.mode(BigDecimal::ROUND_MODE,flag) で何も指定せず、
かつ、引数を指定しない場合は
「小数点以下第一位の数を四捨五入して整数(BigDecimal 値)」にします。
//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").round # => 1
BigDecimal("-1.23......//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").round(4).to_f # => 1.2346
BigDecimal("15.23456").round(-1).to_f # => 20.0
//}
2番目の引数を指定すると、BigDecimal.mode の指定を無視して、指定さ
れた方法で丸め操作を実行します。
//emlist[][rub... -
Float
# round(ndigits = 0) -> Integer | Float (21274.0) -
自身ともっとも近い整数もしくは実数を返します。
...。
//emlist[例][ruby]{
1.0.round # => 1
1.2.round # => 1
(-1.2).round # => -1
(-1.5).round # => -2
t = Math::PI # => 3.141592653589793
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... -
Rational
# round(precision = 0) -> Integer | Rational (21250.0) -
自身ともっとも近い整数を返します。
.../emlist[例][ruby]{
Rational(3).round # => 3
Rational(2, 3).round # => 1
Rational(-3, 2).round # => -2
//}
precision を指定した場合は指定した桁数の数値と、上述の性質に最も近い整
数か Rational を返します。
//emlist[例][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, Rational#truncate... -
BigDecimal
# round -> Integer (21190.0) -
クラスメソッド BigDecimal.mode(BigDecimal::ROUND_MODE,flag) で指定した BigDecimal::ROUND_MODE に従って丸め操作を実行します。
...クラスメソッド BigDecimal.mode(BigDecimal::ROUND_MODE,flag) で指定した
BigDecimal::ROUND_MODE に従って丸め操作を実行します。
@param n 小数点以下の桁数を整数で指定します。
@param b 丸め処理の方式として、BigDecimal.mode の第 1 引数と同じ......gDecimal.mode(BigDecimal::ROUND_MODE,flag) で何も指定せず、
かつ、引数を指定しない場合は
「小数点以下第一位の数を四捨五入して整数(BigDecimal 値)」にします。
//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").round # => 1
BigDecimal("-1.23......//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").round(4).to_f # => 1.2346
BigDecimal("15.23456").round(-1).to_f # => 20.0
//}
2番目の引数を指定すると、BigDecimal.mode の指定を無視して、指定さ
れた方法で丸め操作を実行します。
//emlist[][rub... -
Integer
# round(ndigits = 0 , half: :up) -> Integer (18286.0) -
self ともっとも近い整数を返します。
...self ともっとも近い整数を返します。
@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
@param half ちょうど半分の......:up or nil: 0から遠い方に丸められます。
* :even: もっとも近い偶数に丸められます。
* :down: 0に近い方に丸められます。
//emlist[][ruby]{
1.round # => 1
1.round(2) # => 1
15.round(-1) # => 20
(-15).round(-1) # => -20
25.round(-1, half: :up)......# => 30
25.round(-1, half: :down) # => 20
25.round(-1, half: :even) # => 20
35.round(-1, half: :up) # => 40
35.round(-1, half: :down) # => 30
35.round(-1, half: :even) # => 40
(-25).round(-1, half: :up) # => -30
(-25).round(-1, half: :down) # => -20
(-25).round(-1, half: :even) #... -
Integer
# round(ndigits = 0 , half: :up) -> Integer | Float (18286.0) -
self ともっとも近い整数を返します。
...self ともっとも近い整数を返します。
@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
正の整数を指定した場合、Float を返します。
小数点以下を、最大 n 桁にします。......half ちょうど半分の値の丸め方を指定します。
サポートされている値は以下の通りです。
* :up or nil: 0から遠い方に丸められます。
* :even: もっとも近い偶数に丸められます。
* :down: 0に近い方に丸められます。
//emlis.......round # => 1
1.round(2) # => 1.0
15.round(-1) # => 20
(-15).round(-1) # => -20
25.round(-1, half: :up) # => 30
25.round(-1, half: :down) # => 20
25.round(-1, half: :even) # => 20
35.round(-1, half: :up) # => 40
35.round(-1, half: :down) # => 30
35.round(-1, half... -
Float
# floor(ndigits = 0) -> Integer | Float (9207.0) -
自身と等しいかより小さな整数のうち最大のものを返します。
...合、Float を返します。
小数点以下を、最大 n 桁にします。
負の整数を指定した場合、Integer を返します。
小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[例][ruby]{
1.2.floor #......2.0.floor # => 2
(-1.2).floor # => -2
(-2.0).floor # => -2
1.234567.floor(2) # => 1.23
1.234567.floor(3) # => 1.234
1.234567.floor(4) # => 1.2345
1.234567.floor(5) # => 1.23456
34567.89.floor(-5) # => 0
34567.89.floor(-4) # => 30000
34567.89.floor(-3) # => 34000
34567.89.floor(......-2) # => 34500
34567.89.floor(-1) # => 34560
34567.89.floor(0) # => 34567
34567.89.floor(1) # => 34567.8
34567.89.floor(2) # => 34567.89
34567.89.floor(3) # => 34567.89
//}
@see Numeric#ceil, Numeric#round, Float#truncate... -
Float
# floor -> Integer (9107.0) -
自身と等しいかより小さな整数のうち最大のものを返します。
...自身と等しいかより小さな整数のうち最大のものを返します。
//emlist[例][ruby]{
1.2.floor # => 1
2.0.floor # => 2
(-1.2).floor # => -2
(-2.0).floor # => -2
//}
@see Numeric#ceil, Numeric#round, Float#truncate... -
BigDecimal
# save _ rounding _ mode { . . . } -> object (9101.0) -
丸め処理に関する BigDecimal.mode の設定を保存してブロックを評価します。 ブロック中で変更した設定はブロックの評価後に復元されます。
...丸め処理に関する BigDecimal.mode の設定を保存してブロックを評価します。
ブロック中で変更した設定はブロックの評価後に復元されます。
ブロックの評価結果を返します。...