るりまサーチ (Ruby 2.1.0)

最速Rubyリファレンスマニュアル検索!
20件ヒット [1-20件を表示] (0.446秒)

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

キーワード

検索結果

Integer#abs -> Integer (42307.0)

self の絶対値を返します。

self の絶対値を返します。

//emlist[][ruby]{
-12345.abs # => 12345
12345.abs # => 12345
-1234567890987654321.abs # => 1234567890987654321
//}

Integer#bit_length -> Integer (42307.0)

self を表すのに必要なビット数を返します。

...# => 1
-1.bit_length # => 0
0.bit_length # => 0
1.bit_length # => 1
0xff.bit_length # => 8
0x100.bit_length # => 9
(2**12-1).bit_length # => 12
(2**12).bit_length # => 13
(2**12+1).bit_length # => 13
//}

@see Integer#size...

Integer#magnitude -> Integer (33007.0)

self の絶対値を返します。

self の絶対値を返します。

//emlist[][ruby]{
-12345.abs # => 12345
12345.abs # => 12345
-1234567890987654321.abs # => 1234567890987654321
//}

Integer#<<(bits) -> Integer (24361.0)

シフト演算子。bits だけビットを左にシフトします。

シフト演算子。bits だけビットを左にシフトします。

@param bits シフトさせるビット数

//emlist[][ruby]{
printf("%#b\n", 0b0101 << 1) # => 0b1010
p -1 << 1 # => -2
//}

Integer#>>(bits) -> Integer (24361.0)

シフト演算子。bits だけビットを右にシフトします。

シフト演算子。bits だけビットを右にシフトします。

右シフトは、符号ビット(最上位ビット(MSB))が保持されます。
bitsが実数の場合、小数点以下を切り捨てた値でシフトします。

@param bits シフトさせるビット数

//emlist[][ruby]{
printf("%#b\n", 0b0101 >> 1) # => 0b10
p -1 >> 1 # => -1
//}

絞り込み条件を変える

Integer#<(other) -> bool (24307.0)

比較演算子。数値として小さいか判定します。

比較演算子。数値として小さいか判定します。

@param other 比較対象の数値
@return self よりも other が大きい場合 true を返します。
そうでなければ false を返します。

//emlist[][ruby]{
1 < 1 # => false
1 < 2 # => true
//}

Integer#<=(other) -> bool (24307.0)

比較演算子。数値として等しいまたは小さいか判定します。

比較演算子。数値として等しいまたは小さいか判定します。

@param other 比較対象の数値
@return self よりも other の方が大きい場合か、
両者が等しい場合 true を返します。
そうでなければ false を返します。

//emlist[][ruby]{
1 <= 0 # => false
1 <= 1 # => true
1 <= 2 # => true
//}

Integer#==(other) -> bool (24307.0)

比較演算子。数値として等しいか判定します。

比較演算子。数値として等しいか判定します。

@param other 比較対象の数値
@return self と other が等しい場合 true を返します。
そうでなければ false を返します。

//emlist[][ruby]{
1 == 2 # => false
1 == 1.0 # => true
//}

Integer#===(other) -> bool (24307.0)

比較演算子。数値として等しいか判定します。

比較演算子。数値として等しいか判定します。

@param other 比較対象の数値
@return self と other が等しい場合 true を返します。
そうでなければ false を返します。

//emlist[][ruby]{
1 == 2 # => false
1 == 1.0 # => true
//}

Integer#>(other) -> bool (24307.0)

比較演算子。数値として大きいか判定します。

比較演算子。数値として大きいか判定します。

@param other 比較対象の数値
@return self よりも other の方が小さい場合 true を返します。
そうでなければ false を返します。

//emlist[][ruby]{
1 > 0 # => true
1 > 1 # => false
//}

絞り込み条件を変える

Integer#>=(other) -> bool (24307.0)

比較演算子。数値として等しいまたは大きいか判定します。

比較演算子。数値として等しいまたは大きいか判定します。

@param other 比較対象の数値
@return self よりも other の方が小さい場合か、
両者が等しい場合 true を返します。
そうでなければ false を返します。

//emlist[][ruby]{
1 >= 0 # => true
1 >= 1 # => true
1 >= 2 # => false
//}

Integer#digits(base) -> [Integer] (24307.0)

base を基数として self を位取り記数法で表記した数値を配列で返します。 base を指定しない場合の基数は 10 です。

base を基数として self を位取り記数法で表記した数値を配列で返します。
base を指定しない場合の基数は 10 です。

//emlist[][ruby]{
16.digits # => [6, 1]
16.digits(16) # => [0, 1]
//}

self は非負整数でなければいけません。非負整数でない場合は、Math::DomainErrorが発生します。

//emlist[][ruby]{
-10.digits # Math::DomainError: out of domain が発生
//}

@return 位取り記数法で表した時の数...

Integer#even? -> bool (24307.0)

自身が偶数であれば真を返します。 そうでない場合は偽を返します。

自身が偶数であれば真を返します。
そうでない場合は偽を返します。

//emlist[][ruby]{
10.even? # => true
5.even? # => false
//}

Integer#inspect(base=10) -> String (24307.0)

整数を 10 進文字列表現に変換します。

整数を 10 進文字列表現に変換します。

引数を指定すれば、それを基数とした文字列表
現に変換します。

//emlist[][ruby]{
p 10.to_s(2) # => "1010"
p 10.to_s(8) # => "12"
p 10.to_s(16) # => "a"
p 35.to_s(36) # => "z"
//}

@return 数値の文字列表現
@param base 基数となる 2 - 36 の数値。
@raise ArgumentError base に 2 - 36 以外の数値を指定した場合に発生します。

Integer#odd? -> bool (24307.0)

自身が奇数であれば真を返します。 そうでない場合は偽を返します。

自身が奇数であれば真を返します。
そうでない場合は偽を返します。

//emlist[][ruby]{
5.odd? # => true
10.odd? # => false
//}

絞り込み条件を変える

Integer#to_s(base=10) -> String (24307.0)

整数を 10 進文字列表現に変換します。

整数を 10 進文字列表現に変換します。

引数を指定すれば、それを基数とした文字列表
現に変換します。

//emlist[][ruby]{
p 10.to_s(2) # => "1010"
p 10.to_s(8) # => "12"
p 10.to_s(16) # => "a"
p 35.to_s(36) # => "z"
//}

@return 数値の文字列表現
@param base 基数となる 2 - 36 の数値。
@raise ArgumentError base に 2 - 36 以外の数値を指定した場合に発生します。

Integer#**(other) -> Numeric (24043.0)

算術演算子。冪(べき乗)を計算します。

...に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。

//...

Integer#pow(other) -> Numeric (24043.0)

算術演算子。冪(べき乗)を計算します。

...に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。

//...

Integer#pow(other, modulo) -> Integer (24043.0)

算術演算子。冪(べき乗)を計算します。

...に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。

//...

Integer#[](nth) -> Integer (24025.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...

絞り込み条件を変える