種類
- インスタンスメソッド (88)
- 文書 (24)
- クラス (11)
- ライブラリ (11)
ライブラリ
- ビルトイン (99)
キーワード
-
NEWS for Ruby 2
. 3 . 0 (9) -
NEWS for Ruby 2
. 4 . 0 (8) -
NEWS for Ruby 2
. 5 . 0 (7) - Numeric (11)
- bigdecimal (11)
- ceil (11)
- floor (22)
- round (22)
-
to
_ i (11) - truncate (22)
検索結果
先頭5件
-
Numeric
# round -> Integer (62143.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 (38160.0)
-
数値を表す抽象クラスです。Integer や Float などの数値クラス は Numeric のサブクラスとして実装されています。
...スです。Integer や Float などの数値クラス
は Numeric のサブクラスとして実装されています。
演算や比較を行うメソッド(+, -, *, /, <=>)は Numeric のサブクラスで定義されま
す。Numeric で定義されているメソッドは、サブクラスで......- - - o
remainder | o - - o - - -
round | o o - - o o -
singleton_method_added | o - -......めメソッドの動作一覧
Numeric#ceil, Numeric#floor, Numeric#round, Numeric#truncate
のふるまいの違いの表です。左の実数に対して各メソッドを呼ぶと表のような数を
返します。
| ceil floor round truncate
---------......angular | o - - - o
remainder | o o - - -
round | o o o o -
singleton_method_added | o - - - -... -
Numeric
# ceil -> Integer (21030.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 (21030.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 (21030.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 (21030.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 (21030.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 (18197.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 (18197.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... -
NEWS for Ruby 2
. 4 . 0 (48.0) -
NEWS for Ruby 2.4.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...追加 9969
* Float
* Float#ceil, Float#floor, Float#truncate は
Float#roundと同じように省略可能な桁を指定する引数を受け付けるようになりました。12245
* Float#round は half というキーワード引数を受け付けるようになりました。......ncate は
Integer#round と同じように省略可能な桁を指定する引数を受け付けるようになりました 12245
* Integer#digits を追加。 12447
位置記法のために各桁を展開するためのメソッドです。
* Integer#round は half というキ......es を追加 7418
* Numeric
* Numeric#finite?, Numeric#infinite? を追加 12039
* Process
* macOS 10.12 から導入された CLOCK_MONOTONIC_RAW_APPROX, CLOCK_UPTIME_RAW,
CLOCK_UPTIME_RAW_APPROX をサポートしました
* Rational
* Rational#round は half という... -
Float
# to _ i -> Integer (30.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 (30.0) -
小数点以下を切り捨てて値を整数に変換します。
...小数点以下を切り捨てて値を整数に変換します。
//emlist[例][ruby]{
2.8.truncate # => 2
(-2.8).truncate # => -2
//}
@see Numeric#round, Numeric#ceil, Numeric#floor... -
Float
# truncate(ndigits = 0) -> Integer | Float (30.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 (24.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 (24.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...