462件ヒット
[201-300件を表示]
(0.176秒)
ライブラリ
- ビルトイン (429)
-
bigdecimal
/ util (11) - openssl (11)
- prime (11)
キーワード
- ** (11)
- -@ (11)
- < (11)
- <= (11)
- <=> (11)
- == (11)
- === (11)
- > (11)
- >= (11)
- [] (21)
- allbits? (7)
- anybits? (7)
-
bit
_ length (11) - ceil (11)
- ceildiv (2)
- chr (22)
- digits (22)
- divmod (11)
- downto (22)
- fdiv (11)
- floor (11)
- gcd (11)
- gcdlcm (11)
- lcm (11)
- next (11)
- nobits? (7)
- pow (22)
- pred (11)
-
prime
_ division (11) - remainder (11)
- round (11)
- succ (11)
- times (22)
-
to
_ bn (11) -
to
_ d (11) - truncate (11)
- upto (22)
検索結果
先頭5件
-
Integer
# pow(other) -> Numeric (3303.0) -
算術演算子。冪(べき乗)を計算します。
...乗)を計算します。
@param other 二項演算の右側の引数(対象)
@param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場......。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
//emlist[][ruby]{
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
3.pow(3, 8) # => 3
3.pow(3, -8) # => -5
3.pow(2, -2) # => -1
-3.pow(3, 8) # => 5
-3.pow(3, -8) # => -3
5.pow(2, -8) # => -7
//}
結......数になりそうなとき、警告を出したうえで Float::INFINITY を返します。
//emlist[計算を放棄して Float::INFINITY を返す例][ruby]{
p 100**9999999
# => warning: in a**b, b may be too big
# Infinity
//}
判定の閾値は変わりえます。
@see BigDecimal#power... -
Integer
# pow(other , modulo) -> Integer (3303.0) -
算術演算子。冪(べき乗)を計算します。
...乗)を計算します。
@param other 二項演算の右側の引数(対象)
@param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場......。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
//emlist[][ruby]{
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
3.pow(3, 8) # => 3
3.pow(3, -8) # => -5
3.pow(2, -2) # => -1
-3.pow(3, 8) # => 5
-3.pow(3, -8) # => -3
5.pow(2, -8) # => -7
//}
結......数になりそうなとき、警告を出したうえで Float::INFINITY を返します。
//emlist[計算を放棄して Float::INFINITY を返す例][ruby]{
p 100**9999999
# => warning: in a**b, b may be too big
# Infinity
//}
判定の閾値は変わりえます。
@see BigDecimal#power... -
Integer
# <=>(other) -> -1 | 0 | 1 | nil (3274.0) -
self と other を比較して、self が大きい時に1、等しい時に 0、小さい時 に-1、比較できない時に nil を返します。
...
self と other を比較して、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
# chr -> String (3271.0) -
self を文字コードとして見た時に、引数で与えたエンコーディング encoding に対応する文字を返します。
...
self を文字コードとして見た時に、引数で与えたエンコーディング encoding に対応する文字を返します。
//emlist[][ruby]{
p 65.chr
# => "A"
p 12354.chr
# => `chr': 12354 out of char range (RangeError)
p 12354.chr(Encoding::UTF_8)
# => "あ"
p 12354.chr(Encoding:......or: invalid codepoint 0x3042 in EUC-JP
//}
引数無しで呼ばれた場合は self を US-ASCII、ASCII-8BIT、デフォルト内部エンコーディングの順で優先的に解釈します。
//emlist[][ruby]{
p 0x79.chr.encoding # => #<Encoding:US_ASCII>
p 0x80.chr.encoding # => #<Encoding:......CII_8BIT>
//}
@param encoding エンコーディングを表すオブジェクト。Encoding::UTF_8、'shift_jis' など。
@return 一文字からなる文字列
@raise RangeError self を与えられたエンコーディングで正しく解釈できない場合に発生します。
@see Stri... -
Integer
# downto(min) -> Enumerator (3270.0) -
self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。
...
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#ste......p, Integer#times... -
Integer
# upto(max) {|n| . . . } -> Integer (3269.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
# round(ndigits = 0 , half: :up) -> Integer (3259.0) -
self ともっとも近い整数を返します。
...
self ともっとも近い整数を返します。
@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
@param half ちょうど半分の......* :up or nil: 0から遠い方に丸められます。
* :even: もっとも近い偶数に丸められます。
* :down: 0に近い方に丸められます。
//emlist[][ruby]{
1.round # => 1
1.round(2) # => 1
15.round(-1) # => 20
(-15).round(-1) # => -20
25.round(-1, half: :u......d(-1, half: :down) # => 20
25.round(-1, half: :even) # => 20
35.round(-1, half: :up) # => 40
35.round(-1, half: :down) # => 30
35.round(-1, half: :even) # => 40
(-25).round(-1, half: :up) # => -30
(-25).round(-1, half: :down) # => -20
(-25).round(-1, half: :even) # => -20
//}
@se... -
Integer
# round(ndigits = 0 , half: :up) -> Integer | Float (3259.0) -
self ともっとも近い整数を返します。
...
self ともっとも近い整数を返します。
@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
正の整数を指定した場合、Float を返します。
小数点以下を、最大 n 桁にします。......定した場合、Integer を返します。
小数点位置から左に少なくとも n 個の 0 が並びます。
@param half ちょうど半分の値の丸め方を指定します。
サポートされている値は以下の通りです。
* :up or nil: 0から遠い方......す。
//emlist[][ruby]{
1.round # => 1
1.round(2) # => 1.0
15.round(-1) # => 20
(-15).round(-1) # => -20
25.round(-1, half: :up) # => 30
25.round(-1, half: :down) # => 20
25.round(-1, half: :even) # => 20
35.round(-1, half: :up) # => 40
35.round(-1, half: :down)... -
Integer
# gcdlcm(n) -> [Integer] (3245.0) -
自身と整数 n の最大公約数と最小公倍数の配列 [self.gcd(n), self.lcm(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, 4951760......154835678088235319297]
//}
@see Integer#gcd, Integer#lcm... -
Integer
# pred -> Integer (3245.0) -
self から -1 した値を返します。
...
self から -1 した値を返します。
//emlist[][ruby]{
1.pred #=> 0
(-1).pred #=> -2
//}
@see Integer#next... -
Integer
# floor(ndigits = 0) -> Integer (3235.0) -
self と等しいかより小さな整数のうち最大のものを返します。
...
self と等しいかより小さな整数のうち最大のものを返します。
@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。......//emlist[][ruby]{
1.floor # => 1
1.floor(2) # => 1
18.floor(-1) # => 10
(-18).floor(-1) # => -20
//}
@see Numeric#floor... -
Integer
# floor(ndigits = 0) -> Integer | Float (3235.0) -
self と等しいかより小さな整数のうち最大のものを返します。
...
self と等しいかより小さな整数のうち最大のものを返します。
@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
正の整数を指定した場合、Float を返します。
小数点以下を、最大 n 桁......負の整数を指定した場合、Integer を返します。
小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[][ruby]{
1.floor # => 1
1.floor(2) # => 1.0
18.floor(-1) # => 10
(-18).floor(-1) # => -20
//}
@see Numeric#floor...