ライブラリ
- ビルトイン (433)
-
bigdecimal
/ util (8) - mathn (1)
- openssl (8)
- prime (16)
キーワード
- % (5)
- & (5)
- * (5)
- ** (5)
- + (5)
- - (5)
- -@ (5)
-
/ (5) - < (5)
- << (5)
- <= (5)
- <=> (5)
- == (5)
- === (5)
- > (5)
- >= (5)
- >> (5)
- [] (9)
- ^ (5)
- abs (5)
- allbits? (4)
- anybits? (4)
-
bit
_ length (5) - ceil (8)
- chr (16)
- denominator (8)
- digits (10)
- div (5)
- divmod (5)
- downto (16)
- even? (8)
- fdiv (5)
- floor (8)
- gcd (8)
- gcdlcm (8)
- inspect (5)
- integer? (8)
- lcm (8)
- magnitude (5)
- modulo (5)
- next (8)
- nobits? (4)
- numerator (8)
- odd? (8)
- ord (8)
- pow (8)
- pred (8)
- prime? (8)
-
prime
_ division (8) - rationalize (16)
- remainder (5)
- round (8)
- size (5)
- succ (8)
- times (16)
-
to
_ bn (8) -
to
_ d (8) -
to
_ f (5) -
to
_ i (8) -
to
_ int (8) -
to
_ r (8) -
to
_ s (8) - truncate (8)
- upto (16)
- | (5)
- ~ (5)
検索結果
先頭5件
-
Integer
# %(other) -> Numeric (2.0) -
算術演算子。剰余を計算します。
算術演算子。剰余を計算します。
例:
# 剰余
13 % 4 # => 1
13 % -4 # => -3
-13 % 4 # => 3
-13 % -4 # => -1
@param other 二項演算の右側の引数(対象)
@return 計算結果 -
Integer
# &(other) -> Integer (2.0) -
ビット二項演算子。論理積を計算します。
ビット二項演算子。論理積を計算します。
@param other 数値
例:
1 & 1 # => 1
2 & 3 # => 2 -
Integer
# *(other) -> Numeric (2.0) -
算術演算子。積を計算します。
算術演算子。積を計算します。
@param other 二項演算の右側の引数(対象)
@return 計算結果
例:
# 積
2 * 3 # => 6 -
Integer
# **(other) -> Numeric (2.0) -
算術演算子。冪(べき乗)を計算します。
算術演算子。冪(べき乗)を計算します。
@param other 二項演算の右側の引数(対象)
@return 計算結果
例:
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1...に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。... -
Integer
# +(other) -> Numeric (2.0) -
算術演算子。和を計算します。
算術演算子。和を計算します。
@param other 二項演算の右側の引数(対象)
@return 計算結果
例:
# 和
3 + 4 # => 7 -
Integer
# -(other) -> Numeric (2.0) -
算術演算子。差を計算します。
算術演算子。差を計算します。
@param other 二項演算の右側の引数(対象)
@return 計算結果
例:
# 差
4 - 1 #=> 3 -
Integer
# -@ -> Integer (2.0) -
単項演算子の - です。 self の符号を反転させたものを返します。
単項演算子の - です。
self の符号を反転させたものを返します。
例:
- 10 # => -10
- -10 # => 10 -
Integer
# / (other) -> Numeric (2.0) -
除算の算術演算子。
Fixnum#quo と同じ働きをします(有理数または整数を返します)。
例:
10 / 3 # => 3
require 'mathn'
10 / 3 # => (10/3)...除算の算術演算子。
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
# <(other) -> bool (2.0) -
比較演算子。数値として小さいか判定します。
比較演算子。数値として小さいか判定します。
@param other 比較対象の数値
@return self よりも other が大きい場合 true を返します。
そうでなければ false を返します。
例:
1 < 1 # => false
1 < 2 # => true -
Integer
# <<(bits) -> Integer (2.0) -
シフト演算子。bits だけビットを左にシフトします。
シフト演算子。bits だけビットを左にシフトします。
@param bits シフトさせるビット数
例:
printf("%#b\n", 0b0101 << 1) # => 0b1010
p -1 << 1 # => -2 -
Integer
# <=(other) -> bool (2.0) -
比較演算子。数値として等しいまたは小さいか判定します。
比較演算子。数値として等しいまたは小さいか判定します。
@param other 比較対象の数値
@return self よりも other の方が大きい場合か、
両者が等しい場合 true を返します。
そうでなければ false を返します。
例:
1 <= 0 # => false
1 <= 1 # => true
1 <= 2 # => true -
Integer
# <=>(other) -> -1 | 0 | 1 | nil (2.0) -
self と other を比較して、self が大きい時に1、等しい時に 0、小さい時 に-1、比較できない時に nil を返します。
self と other を比較して、self が大きい時に1、等しい時に 0、小さい時
に-1、比較できない時に nil を返します。
@param other 比較対象の数値
@return -1 か 0 か 1 か nil のいずれか
//emlist[][ruby]{
1 <=> 2 # => -1
1 <=> 1 # => 0
2 <=> 1 # => 1
2 <=> '' # => nil
//} -
Integer
# ==(other) -> bool (2.0) -
比較演算子。数値として等しいか判定します。
比較演算子。数値として等しいか判定します。
@param other 比較対象の数値
@return self と other が等しい場合 true を返します。
そうでなければ false を返します。
例:
1 == 2 # => false
1 == 1.0 # => true -
Integer
# ===(other) -> bool (2.0) -
比較演算子。数値として等しいか判定します。
比較演算子。数値として等しいか判定します。
@param other 比較対象の数値
@return self と other が等しい場合 true を返します。
そうでなければ false を返します。
例:
1 == 2 # => false
1 == 1.0 # => true -
Integer
# >(other) -> bool (2.0) -
比較演算子。数値として大きいか判定します。
比較演算子。数値として大きいか判定します。
@param other 比較対象の数値
@return self よりも other の方が小さい場合 true を返します。
そうでなければ false を返します。
例:
1 > 0 # => true
1 > 1 # => false -
Integer
# >=(other) -> bool (2.0) -
比較演算子。数値として等しいまたは大きいか判定します。
比較演算子。数値として等しいまたは大きいか判定します。
@param other 比較対象の数値
@return self よりも other の方が小さい場合か、
両者が等しい場合 true を返します。
そうでなければ false を返します。
例:
1 >= 0 # => true
1 >= 1 # => true
1 >= 2 # => false -
Integer
# >>(bits) -> Integer (2.0) -
シフト演算子。bits だけビットを右にシフトします。
シフト演算子。bits だけビットを右にシフトします。
右シフトは、符号ビット(最上位ビット(MSB))が保持されます。
bitsが実数の場合、小数点以下を切り捨てた値でシフトします。
@param bits シフトさせるビット数
例:
printf("%#b\n", 0b0101 >> 1) # => 0b10
p -1 >> 1 # => -1 -
Integer
# [](nth) -> Integer (2.0) -
nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。
nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1
を、そうでなければ 0 を返します。
@param nth 何ビット目を指すかの数値
@return 1 か 0
//emlist[][ruby]{
a = 0b11001100101010
30.downto(0) {|n| print a[n] }
# => 0000000000000000011001100101010
a = 9**15
50.downto(0) {|n| print a[n] }
# => 00010111011010000011100001111001010011110...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 (2.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 (2.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
# ^(other) -> Integer (2.0) -
ビット二項演算子。排他的論理和を計算します。
ビット二項演算子。排他的論理和を計算します。
@param other 数値
例:
1 ^ 1 # => 0
2 ^ 3 # => 1 -
Integer
# abs -> Integer (2.0) -
self の絶対値を返します。
self の絶対値を返します。
例:
-12345.abs # => 12345
12345.abs # => 12345
-1234567890987654321.abs # => 1234567890987654321