276件ヒット
[1-100件を表示]
(0.062秒)
種類
- インスタンスメソッド (206)
- 特異メソッド (33)
- 文書 (15)
- クラス (11)
- ライブラリ (11)
ライブラリ
- ビルトイン (184)
- bigdecimal (55)
- stringio (11)
キーワード
-
NEWS for Ruby 2
. 4 . 0 (8) -
NEWS for Ruby 2
. 5 . 0 (7) - Numeric (11)
- bigdecimal (11)
- ceil (33)
- floor (33)
- limit (11)
- mode (22)
- round (41)
-
to
_ i (22)
検索結果
先頭5件
-
Integer
# truncate(ndigits = 0) -> Integer | Float (39238.0) -
0 から self までの整数で、自身にもっとも近い整数を返します。
...定した場合、Integer を返します。
小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[][ruby]{
1.truncate # => 1
1.truncate(2) # => 1.0
18.truncate(-1) # => 10
(-18).truncate(-1) # => -10
//}
@see Numeric#truncate... -
Integer
# truncate(ndigits = 0) -> Integer (39232.0) -
0 から self までの整数で、自身にもっとも近い整数を返します。
...します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[][ruby]{
1.truncate # => 1
1.truncate(2) # => 1
18.truncate(-1) # => 10
(-18).truncate(-1) # => -10
//}
@see Numeric#truncate... -
Numeric
# truncate -> Integer (18226.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... -
BigDecimal
# truncate -> Integer (18215.0) -
小数点以下の数を切り捨てて整数にします。
...ます)。
n が負のときは小数点以上 n 桁目を操作します
(小数点位置から左に少なくとも n 個の 0 が並びます)。
//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").truncate(4).to_f # => 1.2345
BigDecimal("15.23456").truncate(-1).to_f # => 10.0
//}... -
StringIO
# truncate(len) -> Integer (18214.0) -
自身のサイズが len になるように、自身を切り詰め、もしくは拡大します。 拡大した場合は、その部分を 0 で埋めます。 len を返します。
...でない時に発生します。
@raise Errno::EINVAL len がマイナスの時に発生します。
//emlist[例][ruby]{
require "stringio"
a = StringIO.new("hoge", 'r+')
a.truncate(2)
a.string #=> "ho"
a.truncate(5)
a.string #=> "ho\000\000\000"
//}... -
BigDecimal
# truncate(n) -> BigDecimal (18115.0) -
小数点以下の数を切り捨てて整数にします。
...ます)。
n が負のときは小数点以上 n 桁目を操作します
(小数点位置から左に少なくとも n 個の 0 が並びます)。
//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").truncate(4).to_f # => 1.2345
BigDecimal("15.23456").truncate(-1).to_f # => 10.0
//}... -
Float
# truncate(ndigits = 0) -> Integer | Float (15233.0) -
小数点以下を切り捨てて値を整数に変換します。
...を指定した場合、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 N... -
Rational
# truncate(precision = 0) -> Rational | Integer (15227.0) -
小数点以下を切り捨てて値を整数に変換します。
...Rational を返します。
//emlist[例][ruby]{
Rational('-123.456').truncate(+1) # => (-617/5)
Rational('-123.456').truncate(+1).to_f # => -123.4
Rational('-123.456').truncate(0) # => -123
Rational('-123.456').truncate(-1) # => -120
//}
@see Rational#ceil, Rational#floor... -
Float
# truncate -> Integer (15215.0) -
小数点以下を切り捨てて値を整数に変換します。
...小数点以下を切り捨てて値を整数に変換します。
//emlist[例][ruby]{
2.8.truncate # => 2
(-2.8).truncate # => -2
//}
@see Numeric#round, Numeric#ceil, Numeric#floor... -
Float
# to _ i -> Integer (133.0) -
小数点以下を切り捨てて値を整数に変換します。
...を指定した場合、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 N... -
Rational
# to _ i -> Integer (127.0) -
小数点以下を切り捨てて値を整数に変換します。
...Rational を返します。
//emlist[例][ruby]{
Rational('-123.456').truncate(+1) # => (-617/5)
Rational('-123.456').truncate(+1).to_f # => -123.4
Rational('-123.456').truncate(0) # => -123
Rational('-123.456').truncate(-1) # => -120
//}
@see Rational#ceil, Rational#floor... -
Numeric
# floor(ndigits = 0) -> Integer | Float (119.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... -
Float
# to _ i -> Integer (115.0) -
小数点以下を切り捨てて値を整数に変換します。
...小数点以下を切り捨てて値を整数に変換します。
//emlist[例][ruby]{
2.8.truncate # => 2
(-2.8).truncate # => -2
//}
@see Numeric#round, Numeric#ceil, Numeric#floor...