99件ヒット
[1-99件を表示]
(0.072秒)
種類
- インスタンスメソッド (88)
- クラス (11)
検索結果
先頭5件
-
Numeric
# round -> Integer (62145.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#floor, Numeric#truncate... -
Numeric (38162.0)
-
数値を表す抽象クラスです。Integer や Float などの数値クラス は Numeric のサブクラスとして実装されています。
...スです。Integer や Float などの数値クラス
は Numeric のサブクラスとして実装されています。
演算や比較を行うメソッド(+, -, *, /, <=>)は Numeric のサブクラスで定義されま
す。Numeric で定義されているメソッドは、サブクラスで......提供されているメソッド
(+, -, *, /, %) を利用して定義されるものがほとんどです。
つまり Numeric で定義されているメソッドは、Numeric のサブクラスとして新たに数値クラスを定義した時に、
演算メソッド(+, -, *, /, %, <=>, coerce......を表しメソッド定義などではこの記法を利用します。
効率のため Numeric のメソッドと同じメソッドがサブクラスで再定義されている場合があります。
Numeric#coerce メソッドを使うことによって異なる数値クラス間で演算を... -
Numeric
# ceil -> Integer (21032.0) -
自身と等しいかより大きな整数のうち最小のものを返します。
...自身と等しいかより大きな整数のうち最小のものを返します。
//emlist[例][ruby]{
1.ceil #=> 1
1.2.ceil #=> 2
(-1.2).ceil #=> -1
(-1.5).ceil #=> -1
//}
@see Numeric#floor, Numeric#round, Numeric#truncate... -
Numeric
# floor -> Integer (21032.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... -
Numeric
# floor(ndigits = 0) -> Integer (21032.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... -
Numeric
# floor(ndigits = 0) -> Integer | Float (21032.0) -
自身と等しいかより小さな整数のうち最大のものを返します。
...Integer を返します。
小数点位置から左に少なくとも 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... -
Numeric
# truncate -> Integer (21032.0) -
0 から 自身までの整数で、自身にもっとも近い整数を返します。
...0 から 自身までの整数で、自身にもっとも近い整数を返します。
//emlist[例][ruby]{
1.truncate #=> 1
1.2.truncate #=> 1
(-1.2).truncate #=> -1
(-1.5).truncate #=> -1
//}
@see Numeric#ceil, Numeric#floor, Numeric#round... -
Integer
# round(ndigits = 0 , half: :up) -> Integer (18199.0) -
self ともっとも近い整数を返します。
...y]{
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, 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... -
Integer
# round(ndigits = 0 , half: :up) -> Integer | Float (18199.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,......half: :even) # => 40
(-25).round(-1, half: :up) # => -30
(-25).round(-1, half: :down) # => -20
(-25).round(-1, half: :even) # => -20
//}
@see Numeric#round... -
Float
# to _ i -> Integer (32.0) -
小数点以下を切り捨てて値を整数に変換します。
...小数点以下を切り捨てて値を整数に変換します。
//emlist[例][ruby]{
2.8.truncate # => 2
(-2.8).truncate # => -2
//}
@see Numeric#round, Numeric#ceil, Numeric#floor......す。
小数点位置から左に少なくとも 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... -
Float
# truncate -> Integer (32.0) -
小数点以下を切り捨てて値を整数に変換します。
...小数点以下を切り捨てて値を整数に変換します。
//emlist[例][ruby]{
2.8.truncate # => 2
(-2.8).truncate # => -2
//}
@see Numeric#round, Numeric#ceil, Numeric#floor... -
Float
# truncate(ndigits = 0) -> Integer | Float (32.0) -
小数点以下を切り捨てて値を整数に変換します。
...す。
小数点位置から左に少なくとも 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... -
Float
# floor -> Integer (26.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... -
Float
# floor(ndigits = 0) -> Integer | Float (26.0) -
自身と等しいかより小さな整数のうち最大のものを返します。
...oor(-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...