検索結果
先頭5件
-
Integer
# fdiv(other) -> Numeric (24352.0) -
self を other で割った商を Float で返します。 ただし Complex が関わる場合は例外です。 その場合も成分は Float になります。
...指定します。
例:
654321.fdiv(13731) # => 47.652829364212366
654321.fdiv(13731.24) # => 47.65199646936475
-1234567890987654321.fdiv(13731) # => -89910996357705.52
-1234567890987654321.fdiv(13731.24) # => -89909424858035.72
@see Numeric#quo, Numeric#div, Integer#div... -
Integer
# / (other) -> Numeric (24334.0) -
除算の算術演算子。
...除算の算術演算子。
other が Integer の場合、整商(整数の商)を Integer で返します。
普通の商(剰余を考えない商)を越えない最大の整数をもって整商とします。
other が Float、Rational、Complex の場合、普通の商を other と
同......側の引数(対象)
@return 計算結果
//emlist[例][ruby]{
7 / 2 # => 3
7 / -2 # => -4
7 / 2.0 # => 3.5
7 / Rational(2, 1) # => (7/2)
7 / Complex(2, 0) # => ((7/2)+0i)
begin
2 / 0
rescue => e
e # => #<ZeroDivisionError: divided by 0>
end
//}
@see Integer#div, Integer#fdiv, Numeric#quo... -
Integer
# divmod(other) -> [Integer , Numeric] (24334.0) -
self を other で割った商 q と余り r を、 [q, r] という 2 要素の配列にし て返します。 商 q は常に整数ですが、余り r は整数であるとは限りません。
self を other で割った商 q と余り r を、 [q, r] という 2 要素の配列にし
て返します。 商 q は常に整数ですが、余り r は整数であるとは限りません。
@param other self を割る数。
@see Numeric#divmod -
Integer
# remainder(other) -> Numeric (24334.0) -
self を other で割った余り r を返します。
.../emlist[][ruby]{
5.remainder(3) # => 2
-5.remainder(3) # => -2
5.remainder(-3) # => 2
-5.remainder(-3) # => -2
-1234567890987654321.remainder(13731) # => -6966
-1234567890987654321.remainder(13731.24) # => -9906.22531493148
//}
@see Integer#divmod, Integer#modulo, Numeric#modulo... -
Integer
# %(other) -> Numeric (24319.0) -
算術演算子。剰余を計算します。
算術演算子。剰余を計算します。
//emlist[][ruby]{
13 % 4 # => 1
13 % -4 # => -3
-13 % 4 # => 3
-13 % -4 # => -1
//}
@param other 二項演算の右側の引数(対象)
@return 計算結果 -
Integer
# **(other) -> Numeric (24319.0) -
算術演算子。冪(べき乗)を計算します。
...に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
//... -
Integer
# modulo(other) -> Numeric (24319.0) -
算術演算子。剰余を計算します。
算術演算子。剰余を計算します。
//emlist[][ruby]{
13 % 4 # => 1
13 % -4 # => -3
-13 % 4 # => 3
-13 % -4 # => -1
//}
@param other 二項演算の右側の引数(対象)
@return 計算結果 -
Integer
# pow(other) -> Numeric (24319.0) -
算術演算子。冪(べき乗)を計算します。
...に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
//... -
Integer
# *(other) -> Numeric (24316.0) -
算術演算子。積を計算します。
算術演算子。積を計算します。
@param other 二項演算の右側の引数(対象)
@return 計算結果
//emlist[][ruby]{
2 * 3 # => 6
//} -
Integer
# +(other) -> Numeric (24316.0) -
算術演算子。和を計算します。
算術演算子。和を計算します。
@param other 二項演算の右側の引数(対象)
@return 計算結果
//emlist[][ruby]{
3 + 4 # => 7
//} -
Integer
# -(other) -> Numeric (24316.0) -
算術演算子。差を計算します。
算術演算子。差を計算します。
@param other 二項演算の右側の引数(対象)
@return 計算結果
//emlist[][ruby]{
4 - 1 #=> 3
//} -
Integer
# [](nth) -> Integer (24031.0) -
nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。
nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1
を、そうでなければ 0 を返します。
@param nth 何ビット目を指すかの数値
@param len 何ビット分を返すか
@param range 返すビットの範囲
@return self[nth] は 1 か 0
@return self[i, len] は (n >> i) & ((1 << len) - 1) と同じ
@return self[i..j] は (n >> i) & ((1 << (j - i + 1)) - 1) と同じ
@return sel... -
Integer
# [](nth , len) -> Integer (24031.0) -
nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。
nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1
を、そうでなければ 0 を返します。
@param nth 何ビット目を指すかの数値
@param len 何ビット分を返すか
@param range 返すビットの範囲
@return self[nth] は 1 か 0
@return self[i, len] は (n >> i) & ((1 << len) - 1) と同じ
@return self[i..j] は (n >> i) & ((1 << (j - i + 1)) - 1) と同じ
@return sel... -
Integer
# [](range) -> Integer (24031.0) -
nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。
nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1
を、そうでなければ 0 を返します。
@param nth 何ビット目を指すかの数値
@param len 何ビット分を返すか
@param range 返すビットの範囲
@return self[nth] は 1 か 0
@return self[i, len] は (n >> i) & ((1 << len) - 1) と同じ
@return self[i..j] は (n >> i) & ((1 << (j - i + 1)) - 1) と同じ
@return sel... -
Integer
# ceil(ndigits = 0) -> Integer (24031.0) -
self と等しいかより大きな整数のうち最小のものを返します。
self と等しいかより大きな整数のうち最小のものを返します。
@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[][ruby]{
1.ceil # => 1
1.ceil(2) # => 1
18.ceil(-1) # => 20
(-18).ceil(-1) # => -10
//}
@see Numeric#ceil -
Integer
# downto(min) -> Enumerator (24031.0) -
self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。
...で 1 ずつ減らしながらブロックを繰り返し実行します。
self < min であれば何もしません。
@param min 数値
@return self を返します。
//emlist[][ruby]{
5.downto(1) {|i| print i, " " } # => 5 4 3 2 1
//}
@see Integer#upto, Numeric#step, Integer#times... -
Integer
# downto(min) {|n| . . . } -> self (24031.0) -
self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。
...で 1 ずつ減らしながらブロックを繰り返し実行します。
self < min であれば何もしません。
@param min 数値
@return self を返します。
//emlist[][ruby]{
5.downto(1) {|i| print i, " " } # => 5 4 3 2 1
//}
@see Integer#upto, Numeric#step, Integer#times... -
Integer
# floor(ndigits = 0) -> Integer (24031.0) -
self と等しいかより小さな整数のうち最大のものを返します。
self と等しいかより小さな整数のうち最大のものを返します。
@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[][ruby]{
1.floor # => 1
1.floor(2) # => 1
18.floor(-1) # => 10
(-18).floor(-1) # => -20
//}
@see Numeric#floor -
Integer
# round(ndigits = 0 , half: :up) -> Integer (24031.0) -
self ともっとも近い整数を返します。
self ともっとも近い整数を返します。
@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
@param half ちょうど半分の値の丸め方を指定します。
サポートされている値は以下の通りです。
* :up or nil: 0から遠い方に丸められます。
* :even: もっとも近い偶数に丸められます。
* :down: 0に近い方に丸められます。
//emlist[][ruby]{
1.round # =... -
Integer
# times -> Enumerator (24031.0) -
self 回だけ繰り返します。 self が正の整数でない場合は何もしません。
...れます。
//emlist[][ruby]{
3.times { puts "Hello, World!" } # Hello, World! と3行続いて表示される。
0.times { puts "Hello, World!" } # 何も表示されない。
5.times {|n| print n } # 01234 と表示される。
//}
@see Integer#upto, Integer#downto, Numeric#step... -
Integer
# times {|n| . . . } -> self (24031.0) -
self 回だけ繰り返します。 self が正の整数でない場合は何もしません。
...れます。
//emlist[][ruby]{
3.times { puts "Hello, World!" } # Hello, World! と3行続いて表示される。
0.times { puts "Hello, World!" } # 何も表示されない。
5.times {|n| print n } # 01234 と表示される。
//}
@see Integer#upto, Integer#downto, Numeric#step... -
Integer
# truncate(ndigits = 0) -> Integer (24031.0) -
0 から self までの整数で、自身にもっとも近い整数を返します。
0 から self までの整数で、自身にもっとも近い整数を返します。
@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[][ruby]{
1.truncate # => 1
1.truncate(2) # => 1
18.truncate(-1) # => 10
(-18).truncate(-1) # => -10
//}
@see Numeric#truncate -
Integer
# upto(max) -> Enumerator (24031.0) -
self から max まで 1 ずつ増やしながら繰り返します。 self > max であれば何もしません。
...self から max まで 1 ずつ増やしながら繰り返します。
self > max であれば何もしません。
@param max 数値
@return self を返します。
//emlist[][ruby]{
5.upto(10) {|i| print i, " " } # => 5 6 7 8 9 10
//}
@see Integer#downto, Numeric#step, Integer#times... -
Integer
# upto(max) {|n| . . . } -> Integer (24031.0) -
self から max まで 1 ずつ増やしながら繰り返します。 self > max であれば何もしません。
...self から max まで 1 ずつ増やしながら繰り返します。
self > max であれば何もしません。
@param max 数値
@return self を返します。
//emlist[][ruby]{
5.upto(10) {|i| print i, " " } # => 5 6 7 8 9 10
//}
@see Integer#downto, Numeric#step, Integer#times... -
Integer
# pow(other , modulo) -> Integer (24019.0) -
算術演算子。冪(べき乗)を計算します。
...に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
//...