るりまサーチ

最速Rubyリファレンスマニュアル検索!
109件ヒット [1-100件を表示] (0.011秒)
トップページ > クラス:Integer[x]

ライブラリ

キーワード

検索結果

<< 1 2 > >>

Integer#**(other) -> Rational | Float | Integer (1)

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

...を other 乗する数

計算結果は以下のようになります。

* otherが正または0の整数(Integer)ならば、整数(Integer)を返す。
* otherが負の整数(Integer)ならば、有理数(Rational)を返す。
* otherが有理数(Rational)や浮動小数(Float)ならば、...

Integer#/(other) -> Rational | Float | Integer (1)

商を計算します。

...* otherが有理数(Rational)ならば、有理数(Rational)を返す。
* otherがそれ以外なら、Integer#/と同じ。つまり、
other が整数(Integer)ならば、整数(Integer)を(整除)、浮動小数(Float)ならば、
浮動小数(Float)を返す。
ただし、いず...

Integer#chr -> String (1)

文字コードに対応する 1 バイトの文字列を返します。

文字コードに対応する 1 バイトの文字列を返します。

例えば65.chr は "A" を返します。

逆に文字列から文字コードを得るには "A"[0] とします

@return 1バイト文字列

@raise RangeError self が 0 から 255 の範囲外の場合に発生します。

@see String#[]
文字コードに対応する 1 バイトの文字列を返します。

例えば65.chr は "A" を返します。

逆に1文字の文字列から文字コードを得るには "A".ord とします。

@return 1バイト文字列

@raise RangeError self が 0 から 255 の範囲外の場合に発生します。

@see String#ord

Integer#denominator -> Integer (1)

分母(常に1)を返します。

...分母(常に1)を返します。

@return 分母を返します。

@see Integer#numerator...

Integer#downto(min) -> Enumerable::Enumerator (1)

self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。

...し実行します。
self < min であれば何もしません。

@param min 数値
@return self を返します。

@see Integer#upto, Numeric#step, Integer#times...

絞り込み条件を変える

Integer#downto(min) -> Enumerator (1)

self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。

...し実行します。
self < min であれば何もしません。

@param min 数値
@return self を返します。

@see Integer#upto, Numeric#step, Integer#times...

Integer#downto(min) {|n| ... } -> self (1)

self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。

...し実行します。
self < min であれば何もしません。

@param min 数値
@return self を返します。

@see Integer#upto, Numeric#step, Integer#times...

Integer#even? -> bool (1)

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

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

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

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

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

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

3.gcd(0) # => 3
0.gcd(-7) # => 7

@see Integer#lcm, Integer#gcdlcm...
...# => 1
3.gcd(-7) # => 1
((1<<31)-1).gcd((1<<61)-1) # => 1

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

3.gcd(0) # => 3
0.gcd(-7) # => 7

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

Integer#gcd2(int) (1)

@todo

@todo

例:

12.gcd2 8
# => 4

絞り込み条件を変える

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

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

...以外のものを指定すると発生します。

例:

6.gcdlcm(9) # => [3, 18]
2.gcdlcm(2) # => [2, 2]
3.gcdlcm(-7) # => [1, 21]
((1<<31)-1).gcdlcm((1<<61)-1) # => [1, 4951760154835678088235319297]

@see Integer#gcd, Integer#lcm...
...します。

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

例:

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#integer? -> true (1)

常に真を返します。

常に真を返します。

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

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

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

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

3.lcm(0) # => 0
0.lcm(-7) # => 0

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

Integer#next -> Fixnum | Bignum (1)

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

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

Integer#numerator -> Integer (1)

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

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

@return 分子を返します。

@see Integer#denominator...

絞り込み条件を変える

Integer#odd? -> bool (1)

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

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

Integer#ord -> Integer (1)

自身を返します。

自身を返します。

10.ord #=> 10
?a.ord #=> 97
自身を返します。

10.ord #=> 10
# String#ord
?a.ord #=> 97

@see String#ord

Integer#power!(other) -> Integer | Float (1)

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

...計算します。

@param other 自身を other 乗する数

rationalで再定義される前のInteger#**の別名です。
other が正または 0 の整数 (Integer) ならば、整数 (Integer) を、それ以外
なら、浮動小数 (Float) を返します。...

Integer#pred -> Integer (1)

self から -1 した値を返します。

self から -1 した値を返します。

1.pred #=> 0
(-1).pred #=> -2

Integer#prime? -> bool (1)

自身が素数である場合、真を返します。 そうでない場合は偽を返します。

自身が素数である場合、真を返します。
そうでない場合は偽を返します。

例:

1.prime? # => false
2.prime? # => true

@see Prime#prime?

絞り込み条件を変える

Integer#prime_division (1)

@todo

@todo

各素因子について素因子と指数の組を並べた配列を返します。

例:

72.prime_division
# => [[2, 3], [3, 2]]

Integer#prime_division(generator = Prime::Generator23.new) -> [[Integer, Integer]] (1)

自身を素因数分解した結果を返します。

自身を素因数分解した結果を返します。

@param generator 素数生成器のインスタンスを指定します。

@return 素因数とその指数から成るペアを要素とする配列です。つまり、戻り値の各要素は2要素の配列 [n,e] であり、それぞれの内部配列の第1要素 n は self の素因数、第2要素は n**e が self を割り切る最大の自然数 e です。

@raise ZeroDivisionError self がゼロである場合に発生します。

@see Prime#prime_division

例:
12.prime_division #=> [[2,2], [3...

Integer#rationalize -> Rational (1)

自身を Rational に変換します。

自身を Rational に変換します。

@param eps 許容する誤差

引数 eps は常に無視されます。

例:

2.rationalize # => (2/1)
2.rationalize(100) # => (2/1)
2.rationalize(0.1) # => (2/1)

Integer#rationalize(eps) -> Rational (1)

自身を Rational に変換します。

自身を Rational に変換します。

@param eps 許容する誤差

引数 eps は常に無視されます。

例:

2.rationalize # => (2/1)
2.rationalize(100) # => (2/1)
2.rationalize(0.1) # => (2/1)

Integer#succ -> Fixnum | Bignum (1)

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

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

絞り込み条件を変える

Integer#taguri -> String (1)

自身のタグ URI を返します。

自身のタグ URI を返します。

Integer#taguri=(val) (1)

自身のタグ URI を val に設定します。

自身のタグ URI を val に設定します。

@param val タグ URI を文字列で指定します。

Integer#times -> Enumerable::Enumerator (1)

self 回だけ繰り返します。 self が正の整数でない場合は何もしません。

...数値が渡されます。

3.times { puts "Hello, World!" } # Hello, World! と3行続いて表示される。
0.times { puts "Hello, World!" } # 何も表示されない。
5.times {|n| print n } # 01234 と表示される。

@see Integer#upto, Integer#downto, Numeric#step...

Integer#times -> Enumerator (1)

self 回だけ繰り返します。 self が正の整数でない場合は何もしません。

...数値が渡されます。

3.times { puts "Hello, World!" } # Hello, World! と3行続いて表示される。
0.times { puts "Hello, World!" } # 何も表示されない。
5.times {|n| print n } # 01234 と表示される。

@see Integer#upto, Integer#downto, Numeric#step...

Integer#times {|n| ... } -> self (1)

self 回だけ繰り返します。 self が正の整数でない場合は何もしません。

...数値が渡されます。

3.times { puts "Hello, World!" } # Hello, World! と3行続いて表示される。
0.times { puts "Hello, World!" } # 何も表示されない。
5.times {|n| print n } # 01234 と表示される。

@see Integer#upto, Integer#downto, Numeric#step...

絞り込み条件を変える

Integer#to_bn -> OpenSSL::BN (1)

Integer を同じ数を表す OpenSSL::BN のオブジェクトに 変換します。

...Integer を同じ数を表す OpenSSL::BN のオブジェクトに
変換します。

現在のバージョンでは正しく実装されていません。...

Integer#to_d -> BigDecimal (1)

自身を BigDecimal に変換します。BigDecimal(self) と同じです。

自身を BigDecimal に変換します。BigDecimal(self) と同じです。

@return BigDecimal に変換したオブジェクト

Integer#to_i -> self (1)

self を返します。

self を返します。

Integer#to_int -> self (1)

self を返します。

self を返します。

Integer#to_r -> Rational (1)

自身を Rational に変換します。

自身を Rational に変換します。

例:

1.to_r # => Rational(1, 1)
(1<<64).to_r # => Rational(18446744073709551616, 1)
自身を Rational に変換します。

例:

1.to_r # => (1/1)
(1<<64).to_r # => (18446744073709551616/1)

絞り込み条件を変える

Integer#to_s -> String (1)

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

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

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

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#to_s(base) -> String (1)

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

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

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

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#to_yaml(opts = {}) (1)

自身を YAML ドキュメントに変換します。

自身を YAML ドキュメントに変換します。

@param opts YAML ドキュメント出力の際のオプションを指定します。
オプションの詳細は YAML::Syck::Emitter#reset を参照し
てください。

print 1.to_yaml # => --- 1
print -1.to_yaml # => --- -1
自身を YAML ドキュメントに変換します。

@param opts YAML ドキュメント出力の際のオプションを指定します。
オプションの詳細は Syck::Emitter#reset を参照し
てください。

print 1.to_yaml # => --- 1
print -1.to_yaml # => --- -1

Integer#upto(max) -> Enumerable::Enumerator (1)

self から max まで 1 ずつ増やしながら繰り返します。 self > max であれば何もしません。

...繰り返します。
self > max であれば何もしません。

@param max 数値
@return self を返します。

@see Integer#downto, Numeric#step, Integer#times...

Integer#upto(max) -> Enumerator (1)

self から max まで 1 ずつ増やしながら繰り返します。 self > max であれば何もしません。

...繰り返します。
self > max であれば何もしません。

@param max 数値
@return self を返します。

@see Integer#downto, Numeric#step, Integer#times...

絞り込み条件を変える

Integer#upto(max) {|n| ... } -> Fixnum | Bignum (1)

self から max まで 1 ずつ増やしながら繰り返します。 self > max であれば何もしません。

...繰り返します。
self > max であれば何もしません。

@param max 数値
@return self を返します。

@see Integer#downto, Numeric#step, Integer#times...

Integer.each_prime(upper_bound) -> Enumerator (1)

全ての素数を列挙し、それぞれの素数をブロックに渡して評価します。

全ての素数を列挙し、それぞれの素数をブロックに渡して評価します。

@param upper_bound 任意の正の整数を指定します。列挙の上界です。
nil が与えられた場合は無限に列挙し続けます。
@return ブロックの最後に評価された値を返します。
ブロックが与えられなかった場合は、Enumerator と互換性のある外部イテレータを返します。

@see Prime#each
<< 1 2 > >>