369件ヒット
[201-300件を表示]
(0.068秒)
種類
- インスタンスメソッド (259)
- 特異メソッド (96)
- ライブラリ (12)
- 文書 (2)
ライブラリ
- ビルトイン (193)
- bigdecimal (60)
- csv (60)
- pathname (12)
- shell (6)
-
shell
/ command-processor (6) -
shell
/ filter (6) - stringio (12)
クラス
- BigDecimal (60)
- CSV (60)
- File (36)
- Float (69)
- Integer (4)
- Numeric (24)
- Pathname (12)
- Rational (60)
- Shell (6)
-
Shell
:: CommandProcessor (6) -
Shell
:: Filter (6) - StringIO (12)
検索結果
先頭5件
-
Numeric
# floor(ndigits = 0) -> Integer (6106.0) -
自身と等しいかより小さな整数のうち最大のものを返します。
...負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[例][ruby]{
1.floor #=> 1
1.2.floor #=> 1
(-1.2).floor #=> -2
(-1.5).floor #=> -2
//}
@see Numeric#ceil, Numeric#round, Numeric#truncate
@see Integer#floor... -
Rational
# ceil(precision = 0) -> Integer | Rational (6106.0) -
自身と等しいかより大きな整数のうち最小のものを返します。
...//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... -
Rational
# floor(precision = 0) -> Integer | Rational (6106.0) -
自身と等しいかより小さな整数のうち最大のものを返します。
...す。
//emlist[例][ruby]{
Rational(3).floor # => 3
Rational(2, 3).floor # => 0
Rational(-3, 2).floor # => -2
//}
Rational#to_i とは違う結果を返す事に注意してください。
//emlist[例][ruby]{
Rational(+7, 4).to_i # => 1
Rational(+7, 4).floor # => 1
Rational(-7, 4).to_i #......onal(-7, 4).floor # => -2
//}
precision を指定した場合は指定した桁数の数値と、上述の性質に最も近い整
数か Rational を返します。
//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... -
bigdecimal (6006.0)
-
bigdecimal は浮動小数点数演算ライブラリです。 任意の精度で 10 進表現された浮動小数点数を扱えます。
...bigdecimal は浮動小数点数演算ライブラリです。
任意の精度で 10 進表現された浮動小数点数を扱えます。
//emlist[][ruby]{
require 'bigdecimal'
a = BigDecimal("0.123456789123456789")
b = BigDecimal("123456.78912345678", 40)
print a + b # => 0.123456912580245903456......cimal では正確な値を得る事ができます。
//emlist[例1: 0.0001 を 10000 回足す場合。][ruby]{
sum = 0
for i in (1..10000)
sum = sum + 0.0001
end
print sum # => 0.9999999999999062
//}
//emlist[例2: 0.0001 を 10000 回足す場合。(BigDecimal)][ruby]{
require 'bigdecimal'......ます。
: add, sub, mult, div
これらのメソッドは先頭 (最左) の数字からの桁数を指定できます。
//emlist[][ruby]{
require "bigdecimal"
p BigDecimal("2").div(3, 12).to_s(10) # 2.0 / 3.0
# => 0.6666666666 67e0
//}
: truncate, round, ceil, floor
これらのメソ... -
BigDecimal
. mode(s) -> Integer | nil (3112.0) -
BigDecimal の計算処理の制御方法を設定、確認します。
...BigDecimal の計算処理の制御方法を設定、確認します。
第2引数を省略、または nil を指定すると現状の設定値を返します。
@param s 制御方法の設定、確認を行う項目を BigDecimal::EXCEPTION_*、
BigDecimal::ROUND_MODE のいずれか......param v 引数 s が BigDecimal::ROUND_MODE の場合は
BigDecimal::ROUND_MODE 以外の BigDecimal::_ROUND* のいず
れかを指定します。指定した丸め処理が有効になります。
それ以外の場合は、true、false、nil のいずれかを指定し......l::mode(BigDecimal::ROUND_MODE,flag)
//}
の形式で指定します。
ここで、flag は以下(括弧内は対応するインスタンスメソッド)の一つを指定します。
* BigDecimal::ROUND_UP 全て切り上げます。
* BigDecimal::ROUND_DOWN 全て切り捨てます(truncate... -
BigDecimal
. mode(s , v) -> Integer | nil (3112.0) -
BigDecimal の計算処理の制御方法を設定、確認します。
...BigDecimal の計算処理の制御方法を設定、確認します。
第2引数を省略、または nil を指定すると現状の設定値を返します。
@param s 制御方法の設定、確認を行う項目を BigDecimal::EXCEPTION_*、
BigDecimal::ROUND_MODE のいずれか......param v 引数 s が BigDecimal::ROUND_MODE の場合は
BigDecimal::ROUND_MODE 以外の BigDecimal::_ROUND* のいず
れかを指定します。指定した丸め処理が有効になります。
それ以外の場合は、true、false、nil のいずれかを指定し......l::mode(BigDecimal::ROUND_MODE,flag)
//}
の形式で指定します。
ここで、flag は以下(括弧内は対応するインスタンスメソッド)の一つを指定します。
* BigDecimal::ROUND_UP 全て切り上げます。
* BigDecimal::ROUND_DOWN 全て切り捨てます(truncate... -
Float
# round(ndigits = 0) -> Integer | Float (3106.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.141592653589793
t.roun......d(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......、小数点以上の指定された位で四捨五入されます。
@param half ちょうど半分の値の丸め方を指定します。
サポートされている値は以下の通りです。
* :up or nil: 0から遠い方に丸められます。
* :even: もっとも近い偶数に......d(-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 (3106.0) -
自身ともっとも近い整数もしくは実数を返します。
...、小数点以上の指定された位で四捨五入されます。
@param half ちょうど半分の値の丸め方を指定します。
サポートされている値は以下の通りです。
* :up or nil: 0から遠い方に丸められます。
* :even: もっとも近い偶数に......ます。
@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.141592653589793
t.roun......d(-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... -
Rational
# round(precision = 0) -> Integer | Rational (3106.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... -
Float
# to _ i -> Integer (3025.0) -
小数点以下を切り捨てて値を整数に変換します。
...、Float を返します。
小数点以下を、最大 n 桁にします。
負の整数を指定した場合、Integer を返します。
小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[例][ruby]{
2.8.truncate......# => 2
(-2.8).truncate # => -2
1.234567.truncate(2) # => 1.23
34567.89.truncate(-2) # => 34500
//}
@see Numeric#round, Numeric#ceil, Numeric#floor...