るりまサーチ

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

別のキーワード

  1. _builtin to_a
  2. matrix to_a
  3. to_a
  4. dbm to_a
  5. argf.class to_a

ライブラリ

クラス

モジュール

オブジェクト

検索結果

<< 1 2 3 ... > >>

Rational#**(other) -> Rational | Float (21324.0)

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

...

@param other 自身を other 乗する数

other に Float を指定した場合は、計算結果を Float で返しま
す。other が有理数であっても、計算結果が無理数だった場合は Float
を返します。

//emlist[例][ruby]{
r = Rational(3, 4)
r ** Rational(2, 1) #...
...=> (9/16)
r ** 2 # => (9/16)
r ** 2.0 # => 0.5625
r ** Rational(1, 2) # => 0.866025403784439
//}...
...冪(べき)乗を計算します。

@param other 自身を other 乗する数
@raise ArgumentError 計算結果の分母・分子が巨大すぎる場合に発生します。

other に Float を指定した場合は、計算結果を Float で返しま
す。other が有理数であっても、...
...計算結果が無理数だった場合は Float
を返します。

//emlist[例][ruby]{
r = Rational(3, 4)
r ** Rational(2, 1) # => (9/16)
r ** 2 # => (9/16)
r ** 2.0 # => 0.5625
r ** Rational(1, 2) # => 0.866025403784439
//}...

Float#**(other) -> Float (21218.0)

算術演算子。冪を計算します。

...算術演算子。冪を計算します。

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

//emlist[例][ruby]{
# 冪
1.2 ** 3.0 # => 1.7279999999999998
3.0 + 4.5 - 1.3 / 2.4 * 3 % 1.2 ** 3.0 # => 5.875
0.0 ** 0 # => 1.0
//}...

BigDecimal#**(n) -> BigDecimal (21200.0)

self の n 乗を計算します。

...self の n 乗を計算します。

戻り値の有効桁数は self の有効桁数の n 倍以上になります。

@param n selfを other 乗する数を指定します。

@param prec 有効桁数を整数で指定します。...
...self の n 乗を計算します。

戻り値の有効桁数は self の有効桁数の n 倍以上になります。

@param n selfを other 乗する数を指定します。

@param prec 有効桁数を整数で指定します。


@see Integer#pow...

Matrix#**(n) -> Matrix (21200.0)

self の n 乗を返します。

...self の n 乗を返します。

@param n べき数の指定
@raise ExceptionForMatrix::ErrNotRegular n が 0 以下で、行列が正則でない場合に発生します...

Rational#**(rhs) -> Numeric (21100.0)

@todo

...@todo

self のべき乗を返します。 Rational になるようであれば Rational で返します。...

絞り込み条件を変える

Bignum#**(other) -> Fixnum | Bignum | Float (18218.0)

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

...算術演算子。冪(べき乗)を計算します。

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

2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1...

Fixnum#**(other) -> Fixnum | Bignum | Float (18218.0)

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

...算術演算子。冪(べき乗)を計算します。

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

2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1...

Integer#**(other) -> Numeric (18142.0)

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

...param other 二項演算の右側の引数(対象)
@param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@ra...
...ise 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...

Marshal フォーマット (6510.0)

Marshal フォーマット フォーマットバージョン 4.8 を元に記述しています。

...Marshal フォーマット
フォーマットバージョン 4.8 を元に記述しています。

=== nil, true, false

それぞれ、'0', 'T', 'F' になります。

//emlist[][ruby]{
p Marshal.dump(nil).unpack1("x2 a*") # => "0"
p Marshal.dump(true).unpack1("x2 a*") # => "T"
p Marshal.dump...
...(false).unpack1("x2 a*") # => "F"
//}

Ruby 2.1 以前では、インスタンス変数を設定しても dump されません。
Ruby 2.2 以降は freeze されているので、インスタンス変数は設定できません。

=== Fixnum

'i' に続けて Fixnum を表すデータ構造が続...
...的に Bignum になる Integer は
64ビット環境で Marshal.dump しても、この形式になります。

//emlist{
| 'l' | '+'/'-' | shortの個数(Fixnum形式) | ... |
//}

//emlist[][ruby]{
p Marshal.dump(2**32).unpack("x2 a a c a*")
# => ["l", "+", 8, "\x00\x00\x00\x00\x01\x00"]
//}

ru...

パターンマッチ (6420.0)

パターンマッチ * patterns * variable_binding * variable_pinning * matching_non_primitive_objects * guard_clauses * current_feature_status * pattern_syntax * some_undefined_behavior_examples

...パターンマッチ
* patterns
* variable_binding
* variable_pinning
* matching_non_primitive_objects
* guard_clauses
* current_feature_status
* pattern_syntax
* some_undefined_behavior_examples

パターンマッチは、構造化された値に対して、構造をチェック...
...<expression> in <pattern>

case 文の中で利用できます。

case <expression>
in <pattern1>
...
in <pattern2>
...
in <pattern3>
...
else
...
end

in 節と when 節は1つの case 式の中に混ぜて書くことはできません。


case/in 式は 「網羅...
..."matched"
else
"not matched"
end
#=> "not matched"
//}

//emlist[][ruby]{
case {}
in {}
"matched"
else
"not matched"
end
#=> "matched"
//}

また、パターンで明示的に指定したキー以外のキーが存在しないハッシュにのみ、マッチさせたい場合には、『**ni...
...りません)

Rubyでのパターンマッチは case/in 式を用いて実装されています。

case <expression>
in <pattern1>
...
in <pattern2>
...
in <pattern3>
...
else
...
end

in 節と when 節は1つの case 式の中に混ぜて書くことはできませ...

絞り込み条件を変える

Kernel.#format(format, *arg) -> String (6308.0)

format 文字列を C 言語の sprintf と同じように解釈し、 引数をフォーマットした文字列を返します。

...format 文字列を C 言語の sprintf と同じように解釈し、
引数をフォーマットした文字列を返します。

@param format フォーマット文字列です。
@param arg フォーマットされる引数です。
@see Kernel.#printf,Time#strftime,Date.strptime

=== sprintf...
...トの書式です。[] で囲まれた部分は省略可
能であることを示しています。

%[nth$][フラグ][幅][.精度]指示子
%[<name>][フラグ][幅][.精度]指示子

`%' 自身を出力するには `%%' とします。

以下それぞれの要素に関して説明します...
...0 ** 6) #=> "1e+06"
p sprintf("%g", 10 ** -5) #=> "1e-05"
//}
精度の省略値は 6 です。

無限大、NaN(Not a Number) に対する出力は以下のとおりです。
//emlist[][ruby]{
p sprintf("%f", 1.0/0) #=> "inf"
p sprintf("%f", -1.0/0) #=> "-inf"
p sprintf("%f", 0.0/0) #=> "na...
<< 1 2 3 ... > >>