るりまサーチ

最速Rubyリファレンスマニュアル検索!
803件ヒット [401-500件を表示] (0.013秒)
トップページ > クラス:Integer[x] > 種類:インスタンスメソッド[x]

ライブラリ

キーワード

検索結果

<< < ... 3 4 5 6 7 ... > >>

Integer#gcd(n) -> Integer (2.0)

自身と整数 n の最大公約数を返します。

...7) # => 1
((1<<31)-1).gcd((1<<61)-1) # => 1
//}

また、self や n が 0 だった場合は、0 ではない方の整数の絶対値を返します。

//emlist[][ruby]{
3.gcd(0) # => 3
0.gcd(-7) # => 7
//}

@see Integer#lcm, Integer#gcdlcm...

Integer#gcdlcm(n) -> [Integer] (2.0)

自身と整数 n の最大公約数と最小公倍数の配列 [self.gcd(n), self.lcm(n)] を返します。

...@raise ArgumentError n に整数以外のものを指定すると発生します。

//emlist[][ruby]{
2.gcdlcm(2) # => [2, 2]
3.gcdlcm(-7) # => [1, 21]
((1<<31)-1).gcdlcm((1<<61)-1) # => [1, 4951760154835678088235319297]
//}

@see Integer#gcd, Integer#lcm...

Integer#inspect(base=10) -> String (2.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#integer? -> true (2.0)

常に真を返します。

...常に真を返します。

//emlist[][ruby]{
1.integer? # => true
1.0.integer? # => false
//}...

Integer#lcm(n) -> Integer (2.0)

自身と整数 n の最小公倍数を返します。

...3.lcm(-7) # => 21
((1<<31)-1).lcm((1<<61)-1) # => 4951760154835678088235319297
//}

また、self や n が 0 だった場合は、0 を返します。

//emlist[][ruby]{
3.lcm(0) # => 0
0.lcm(-7) # => 0
//}

@see Integer#gcd, Integer#gcdlcm...

絞り込み条件を変える

Integer#magnitude -> Integer (2.0)

self の絶対値を返します。

self の絶対値を返します。

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

Integer#modulo(other) -> Numeric (2.0)

算術演算子。剰余を計算します。

算術演算子。剰余を計算します。

//emlist[][ruby]{
13 % 4 # => 1
13 % -4 # => -3
-13 % 4 # => 3
-13 % -4 # => -1
//}

@param other 二項演算の右側の引数(対象)
@return 計算結果

Integer#next -> Integer (2.0)

self の次の整数を返します。

...self の次の整数を返します。

//emlist[][ruby]{
1.next #=> 2
(-1).next #=> 0
1.succ #=> 2
(-1).succ #=> 0
//}

@see Integer#pred...

Integer#nobits?(mask) -> bool (2.0)

self & mask のすべてのビットが 0 なら true を返します。

...am mask ビットマスクを整数で指定します。

//emlist[][ruby]{
42.nobits?(42) # => false
0b1010_1010.nobits?(0b1000_0010) # => false
0b1010_1010.nobits?(0b1000_0001) # => false
0b0100_0101.nobits?(0b1010_1010) # => true
//}

@see Integer#allbits?
@see Integer#anybits?...

Integer#numerator -> Integer (2.0)

分子(常に自身)を返します。

...分子(常に自身)を返します。

@return 分子を返します。

//emlist[][ruby]{
10.numerator # => 10
-10.numerator # => -10
//}

@see Integer#denominator...

絞り込み条件を変える

<< < ... 3 4 5 6 7 ... > >>