るりまサーチ

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

別のキーワード

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

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

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

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

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

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

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

Integer#integer? -> true (23215.0)

常に真を返します。

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

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

Integer#>>(bits) -> Integer (23203.0)

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

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

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

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

Integer#<=>(other) -> -1 | 0 | 1 | nil (23102.0)

self と other を比較して、self が大きい時に1、等しい時に 0、小さい時 に-1、比較できない時に nil を返します。

...、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 (23102.0)

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

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

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

絞り込み条件を変える

Integer#div(other) -> Integer (17251.0)

整商(整数の商)を返します。 普通の商(剰余を考えない商)を越えない最大の整数をもって整商とします。

...ther が Integer オブジェクトの場合、Integer#/ の結果と一致します。

div に対応する剰余メソッドは modulo です。

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

//emlist[例][ruby]{
7.div(2) # => 3
7.div(-2) # => -4
7.div(2.0) # => 3
7.div...
...)) # => 3

begin
2.div(0)
rescue => e
e # => #<ZeroDivisionError: divided by 0>
end

begin
2.div(0.0)
rescue => e
e # => #<ZeroDivisionError: divided by 0>
# Integer#/ と違い、引数が Float でもゼロで割ることはできない
end
//}

@see Integer#fdiv, Integer#/, Integer#modu...

Integer#upto(max) {|n| ... } -> Integer (17231.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#gcd(n) -> Integer (17215.0)

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

...# => 2
3.gcd(7) # => 1
3.gcd(-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] (17215.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#lcm(n) -> Integer (17215.0)

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

...# => 2
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#gc...

絞り込み条件を変える

<< 1 2 3 ... > >>