ライブラリ
- ビルトイン (190)
- bigdecimal (165)
-
irb
/ cmd / subirb (11) - matrix (33)
- nkf (11)
- socket (22)
クラス
- BigDecimal (165)
- Float (70)
-
IRB
:: ExtendCommand :: Foreground (11) - Integer (11)
- Matrix (33)
- Numeric (44)
- Rational (33)
- Socket (11)
- Time (21)
モジュール
-
Socket
:: Constants (11)
キーワード
-
NEWS for Ruby 2
. 3 . 0 (9) -
NEWS for Ruby 2
. 4 . 0 (8) -
NEWS for Ruby 2
. 5 . 0 (7) - NKF (11)
- Numeric (11)
- ROUNDS (7)
-
ROUND
_ CEILING (11) -
ROUND
_ DOWN (11) -
ROUND
_ FLOOR (11) -
ROUND
_ HALF _ DOWN (11) -
ROUND
_ HALF _ EVEN (11) -
ROUND
_ HALF _ UP (11) -
ROUND
_ MODE (11) -
ROUND
_ UP (11) -
SOPRI
_ BACKGROUND (22) - bigdecimal (11)
- ceil (38)
- eigen (11)
- eigensystem (11)
- execute (11)
- floor (38)
- limit (11)
- mode (22)
-
save
_ rounding _ mode (11) -
to
_ i (11) - truncate (22)
検索結果
先頭5件
-
Float
# round(ndigits = 0) -> Integer | Float (18328.0) -
自身ともっとも近い整数もしくは実数を返します。
...自身ともっとも近い整数もしくは実数を返します。
中央値 0.5, -0.5 はそれぞれ 1,-1 に切り上げされます。
いわゆる四捨五入ですが、偶数丸めではありません。
@param ndigits 丸める位を指定します。
ndigitsが0ならば、小......{
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
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#truncate... -
Float
# round(ndigits = 0 , half: :up) -> Integer | Float (18328.0) -
自身ともっとも近い整数もしくは実数を返します。
...自身ともっとも近い整数もしくは実数を返します。
中央値 0.5, -0.5 はそれぞれ 1,-1 に切り上げされます。
いわゆる四捨五入ですが、偶数丸めではありません。
@param ndigits 丸める位を指定します。
ndigitsが0ならば、小......{
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
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#truncate... -
Time
# round(ndigits=0) -> Time (18327.0) -
十進小数点数で指定した桁数の精度で丸めをし、 その Time オブジェクトを返します。 (デフォルトは0、つまり小数点の所で丸めます)。
...4).round.iso8601(3)) # => "1999-12-31T23:59:59.000Z"
p((t + 0.49).round.iso8601(3)) # => "1999-12-31T23:59:59.000Z"
p((t + 0.5).round.iso8601(3)) # => "2000-01-01T00:00:00.000Z"
p((t + 1.4).round.iso8601(3)) # => "2000-01-01T00:00:00.000Z"
p((t + 1.49).round.iso8601(3)) # => "2000-01-01......T00:00:00.000Z"
p((t + 1.5).round.iso8601(3)) # => "2000-01-01T00:00:01.000Z"
t = Time.utc(1999,12,31, 23,59,59)
p (t + 0.123456789).round(4).iso8601(6) # => "1999-12-31T23:59:59.123500Z"
//}......T00:00:00.000Z"
p((t + 1.5).round.iso8601(3)) # => "2000-01-01T00:00:01.000Z"
t = Time.utc(1999,12,31, 23,59,59)
p (t + 0.123456789).round(4).iso8601(6) # => "1999-12-31T23:59:59.123500Z"
//}
@see Time#ceil, Time#floor... -
Integer
# round(ndigits = 0 , half: :up) -> Integer (18309.0) -
self ともっとも近い整数を返します。
...]{
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, ha......lf: :even) # => 40
(-25).round(-1, half: :up) # => -30
(-25).round(-1, half: :down) # => -20
(-25).round(-1, half: :even) # => -20
//}
@see Numeric#round... -
Integer
# round(ndigits = 0 , half: :up) -> Integer | Float (18309.0) -
self ともっとも近い整数を返します。
...{
1.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, h......alf: :even) # => 40
(-25).round(-1, half: :up) # => -30
(-25).round(-1, half: :down) # => -20
(-25).round(-1, half: :even) # => -20
//}
@see Numeric#round... -
BigDecimal
# round -> Integer (18295.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 引数と同......al::ROUND_MODE,flag) で何も指定せず、
かつ、引数を指定しない場合は
「小数点以下第一位の数を四捨五入して整数(BigDecimal 値)」にします。
//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").round # => 1
BigDecimal("-1.23456").round # => -1
/......456").round(4).to_f # => 1.2346
BigDecimal("15.23456").round(-1).to_f # => 20.0
//}
2番目の引数を指定すると、BigDecimal.mode の指定を無視して、指定さ
れた方法で丸め操作を実行します。
//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").round(3,Bi... -
BigDecimal
# round(n) -> BigDecimal (18295.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 引数と同......al::ROUND_MODE,flag) で何も指定せず、
かつ、引数を指定しない場合は
「小数点以下第一位の数を四捨五入して整数(BigDecimal 値)」にします。
//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").round # => 1
BigDecimal("-1.23456").round # => -1
/......456").round(4).to_f # => 1.2346
BigDecimal("15.23456").round(-1).to_f # => 20.0
//}
2番目の引数を指定すると、BigDecimal.mode の指定を無視して、指定さ
れた方法で丸め操作を実行します。
//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").round(3,Bi... -
BigDecimal
# round(n , b) -> BigDecimal (18295.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 引数と同......al::ROUND_MODE,flag) で何も指定せず、
かつ、引数を指定しない場合は
「小数点以下第一位の数を四捨五入して整数(BigDecimal 値)」にします。
//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").round # => 1
BigDecimal("-1.23456").round # => -1
/......456").round(4).to_f # => 1.2346
BigDecimal("15.23456").round(-1).to_f # => 20.0
//}
2番目の引数を指定すると、BigDecimal.mode の指定を無視して、指定さ
れた方法で丸め操作を実行します。
//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").round(3,Bi... -
Float
# round(ndigits = 0) -> Integer | Float (18291.0) -
自身ともっとも近い整数もしくは実数を返します。
...自身ともっとも近い整数もしくは実数を返します。
中央値 0.5, -0.5 はそれぞれ 1,-1 に切り上げされます。
いわゆる四捨五入ですが、偶数丸めではありません。
@param ndigits 丸める位を指定します。
ndigitsが0ならば、小......{
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 (18285.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......す。
//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#f... -
Numeric
# round -> Integer (18243.0) -
自身ともっとも近い整数を返します。
...返します。
中央値 0.5, -0.5 はそれぞれ 1,-1 に切り上げされます。いわゆる四捨五入ですが、偶数丸めではありません。
//emlist[例][ruby]{
1.round #=> 1
1.2.round #=> 1
(-1.2).round #=> -1
(-1.5).round #=> -2
//}
@see Numeric#ceil, Numeric... -
Matrix
# round(ndigits = 0) -> Matrix (18207.0) -
行列の各要素を指定した桁数で丸めた行列を返します。
...行列の各要素を指定した桁数で丸めた行列を返します。
@see Float#round...