るりまサーチ

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

別のキーワード

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

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

Integer#integer? -> true (23115.0)

常に真を返します。

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

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

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

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

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

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

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

@param other 二項演算の右側...
...=> 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#modulo...

Integer#gcd(n) -> Integer (17115.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] (17115.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 (17115.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#upto(max) {|n| ... } -> Integer (17115.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#next -> Integer (17110.0)

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

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

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

@see Integer#pred...

Integer#succ -> Integer (17110.0)

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

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

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

@see Integer#pred...

Integer#bit_length -> Integer (17109.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#ceil(ndigits = 0) -> Integer | Float (17109.0)

self と等しいかより大きな整数のうち最小のものを返します。

...合、Float を返します。
小数点以下を、最大 n 桁にします。
負の整数を指定した場合、Integer を返します。
小数点位置から左に少なくとも n 個の 0 が並びます。

//emlist[][ruby]{
1.ceil # =...

絞り込み条件を変える

<< 1 2 3 ... > >>