722件ヒット
[101-200件を表示]
(0.079秒)
別のキーワード
キーワード
- % (12)
- & (12)
- * (12)
- ** (12)
- + (12)
- - (12)
- -@ (12)
-
/ (11) - < (12)
- << (12)
- <= (12)
- <=> (12)
- == (12)
- === (12)
- > (12)
- >= (12)
- >> (12)
- [] (24)
- ^ (12)
- allbits? (8)
- anybits? (8)
-
bit
_ length (12) - ceil (12)
- ceildiv (3)
- chr (24)
- denominator (12)
- digits (24)
- div (12)
- downto (24)
- floor (12)
- gcd (12)
- gcdlcm (12)
- inspect (12)
- lcm (12)
- modulo (12)
- next (12)
- nobits? (8)
- numerator (12)
- ord (12)
- pow (24)
- pred (12)
- prime? (12)
-
prime
_ division (12) - rationalize (24)
- remainder (12)
- round (12)
- size (12)
- succ (12)
- times (24)
-
to
_ bn (12) -
to
_ s (12) - truncate (12)
- upto (24)
- | (12)
検索結果
先頭5件
-
Integer
# digits -> [Integer] (50.0) -
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 位......取り記数法で表した時の数値の配列
@param base 基数となる数値。
@raise ArgumentError base に正の整数以外を指定した場合に発生します。
@raise Math::DomainError 非負整数以外に対して呼び出した場合に発生します。... -
Integer
# digits(base) -> [Integer] (50.0) -
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 位......取り記数法で表した時の数値の配列
@param base 基数となる数値。
@raise ArgumentError base に正の整数以外を指定した場合に発生します。
@raise Math::DomainError 非負整数以外に対して呼び出した場合に発生します。... -
Integer
# [](nth) -> Integer (38.0) -
nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。
...下位ビット(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.d......11000011110010100111100010111001
//}
n[i] は (n >> i) & 1 と等価なので、負のインデックスは常に 0 を返します。
//emlist[][ruby]{
p 255[-1] # => 0
//}
self[nth]=bit (つまりビットの修正) がないのは、Numeric 関連クラスが
immutable であるためです... -
Integer
# gcd(n) -> Integer (38.0) -
自身と整数 n の最大公約数を返します。
...自身と整数 n の最大公約数を返します。
@raise ArgumentError n に整数以外のものを指定すると発生します。
//emlist[][ruby]{
2.gcd(2) # => 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
# lcm(n) -> Integer (38.0) -
自身と整数 n の最小公倍数を返します。
...自身と整数 n の最小公倍数を返します。
@raise ArgumentError n に整数以外のものを指定すると発生します。
//emlist[][ruby]{
2.lcm(2) # => 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#gcdlcm... -
Integer
# prime _ division(generator = Prime :: Generator23 . new) -> [[Integer , Integer]] (38.0) -
自身を素因数分解した結果を返します。
...自身を素因数分解した結果を返します。
@param generator 素数生成器のインスタンスを指定します。
@return 素因数とその指数から成るペアを要素とする配列です。つまり、戻り値の各要素は2要素の配列 [n,e] であり、それぞれ......の素因数、第2要素は n**e が self を割り切る最大の自然数 e です。
@raise ZeroDivisionError self がゼロである場合に発生します。
@see Prime#prime_division
//emlist[例][ruby]{
require 'prime'
12.prime_division #=> [[2,2], [3,1]]
10.prime_division #=> [[2,1], [5... -
Integer
# / (other) -> Numeric (32.0) -
除算の算術演算子。
...除算の算術演算子。
other が Integer の場合、整商(整数の商)を Integer で返します。
普通の商(剰余を考えない商)を越えない最大の整数をもって整商とします。
other が Float、Rational、Complex の場合、普通の商を other と
同......
@param other 二項演算の右側の引数(対象)
@return 計算結果
//emlist[例][ruby]{
7 / 2 # => 3
7 / -2 # => -4
7 / 2.0 # => 3.5
7 / Rational(2, 1) # => (7/2)
7 / Complex(2, 0) # => ((7/2)+0i)
begin
2 / 0
rescue => e
e # => #<ZeroDivisionError: divided by 0>
end
//}
@see Integer#d......iv, Integer#fdiv, Numeric#quo... -
Integer
# allbits?(mask) -> bool (32.0) -
self & mask の全てのビットが 1 なら true を返します。
...
@param mask ビットマスクを整数で指定します。
//emlist[][ruby]{
42.allbits?(42) # => true
0b1010_1010.allbits?(0b1000_0010) # => true
0b1010_1010.allbits?(0b1000_0001) # => false
0b1000_0010.allbits?(0b1010_1010) # => false
//}
@see Integer#anybits?
@see Integer#... -
Integer
# anybits?(mask) -> bool (32.0) -
self & mask のいずれかのビットが 1 なら true を返します。
...
@param mask ビットマスクを整数で指定します。
//emlist[][ruby]{
42.anybits?(42) # => true
0b1010_1010.anybits?(0b1000_0010) # => true
0b1010_1010.anybits?(0b1000_0001) # => true
0b1000_0010.anybits?(0b0010_1100) # => false
//}
@see Integer#allbits?
@see Integer#n... -
Integer
# div(other) -> Integer (32.0) -
整商(整数の商)を返します。 普通の商(剰余を考えない商)を越えない最大の整数をもって整商とします。
...整商とします。
other が Integer オブジェクトの場合、Integer#/ の結果と一致します。
div に対応する剰余メソッドは modulo です。
@param other 二項演算の右側の引数(対象)
@return 計算結果
//emlist[例][ruby]{
7.div(2) # => 3
7.div(-2) # => -4......=> 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
# downto(min) -> Enumerator (32.0) -
self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。
...で 1 ずつ減らしながらブロックを繰り返し実行します。
self < min であれば何もしません。
@param min 数値
@return self を返します。
//emlist[][ruby]{
5.downto(1) {|i| print i, " " } # => 5 4 3 2 1
//}
@see Integer#upto, Numeric#step, Integer#times...