7件ヒット
[1-7件を表示]
(0.026秒)
検索結果
先頭5件
-
Rational
# ceil(precision = 0) -> Integer | Rational (54457.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]{
Ra... -
Float
# round(ndigits = 0) -> Integer | Float (46.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) #... -
Float
# round(ndigits = 0 , half: :up) -> Integer | Float (46.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) #... -
Rational
# floor(precision = 0) -> Integer | Rational (46.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 とは違う結果を返す事に注意してください。
//emlist[例][ruby]{
Rational(+7, 4).to_i # => ... -
Rational
# round(precision = 0) -> Integer | Rational (46.0) -
自身ともっとも近い整数を返します。
自身ともっとも近い整数を返します。
中央値 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
//}
precision を指定した場合は指定した桁数の数値と、上述の性質に最も近い整
数か Rational を返し... -
Rational
# to _ i -> Integer (46.0) -
小数点以下を切り捨てて値を整数に変換します。
小数点以下を切り捨てて値を整数に変換します。
@param precision 計算結果の精度
@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
# truncate(precision = 0) -> Rational | Integer (46.0) -
小数点以下を切り捨てて値を整数に変換します。
小数点以下を切り捨てて値を整数に変換します。
@param precision 計算結果の精度
@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 を指定した場合は指定した桁数で切り...