るりまサーチ (Ruby 2.4.0)

最速Rubyリファレンスマニュアル検索!
7件ヒット [1-7件を表示] (0.198秒)
トップページ > バージョン:2.4.0[x] > 種類:インスタンスメソッド[x] > クエリ:n[x] > クエリ:d[x] > クラス:Rational[x]

別のキーワード

  1. etc sc_xopen_enh_i18n
  2. rsa n
  3. rsa n=
  4. openssl n
  5. openssl n=

ライブラリ

キーワード

検索結果

Rational#denominator -> Integer (45607.0)

分母を返します。常に正の整数を返します。

...分母を返します。常に正の整数を返します。

@return 分母を返します。

//emlist[例][ruby]{
Rational
(7).denominator # => 1
Rational
(7, 1).denominator # => 1
Rational
(9, -4).denominator # => 4
Rational
(-2, -10).denominator # => 5
//}

@see Rational#numerator...

Rational#round(precision = 0) -> Integer | Rational (36607.0)

自身ともっとも近い整数を返します。

...//emlist[例][ruby]{
Rational
(3).round # => 3
Rational
(2, 3).round # => 1
Rational
(-3, 2).round # => -2
//}

precision を指定した場合は指定した桁数の数値と、上述の性質に最も近い整
数か Rational を返します。

//emlist[例][ruby]{
Rational
('-123.456').round(+...
...1) # => (-247/2)
Rational
('-123.456').round(+1).to_f # => -123.5
Rational
('-123.456').round(0) # => -123
Rational
('-123.456').round(-1) # => -120
Rational
('-123.456').round(-2) # => -100
//}

@see Rational#ceil, Rational#floor, Rational#truncate...

Rational#to_d(nFig) -> BigDecimal (27646.0)

自身を BigDecimal に変換します。

...桁数

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

@raise ArgumentError nFig に 0 以下を指定した場合に発生します。

//emlist[][ruby]{
require "bigdecimal"
require "bigdecimal/util"
p Rational(1, 3).to_d(3) # => 0.333e0
p Rational(1, 3).to_d(10) # => 0.3333333333e0
//}...

Rational#magnitude -> Rational (27607.0)

自身の絶対値を返します。

...自身の絶対値を返します。

//emlist[例][ruby]{
Rational
(1, 2).abs # => (1/2)
Rational
(-1, 2).abs # => (1/2)
//}...

Rational#fdiv(other) -> Float (27307.0)

self を other で割った商を Float で返します。 other に虚数を指定することは出来ません。

...@param other 自身を割る数

//emlist[例][ruby]{
Rational
(2, 3).fdiv(1) # => 0.6666666666666666
Rational
(2, 3).fdiv(0.5) # => 1.3333333333333333
Rational
(2).fdiv(3) # => 0.6666666666666666

Rational
(1).fdiv(Complex(1, 0)) # => 1.0
Rational
(1).fdiv(Complex(0, 1)) # => RangeError
//}...

絞り込み条件を変える

Rational#marshal_dump -> Array (27307.0)

Marshal.#load のためのメソッドです。 Rational::compatible#marshal_load で復元可能な配列を返します。

...Marshal.#load のためのメソッドです。
Rational
::compatible#marshal_load で復元可能な配列を返します。

[注意] Rational::compatible は通常の方法では参照する事ができません。...

Rational#to_json(*args) -> String (18343.0)

自身を JSON 形式の文字列に変換して返します。

...JSON::Generator::GeneratorMethods::Hash#to_json を呼び出しています。

@param args 使用しません。

//emlist[例][ruby]{
require 'json/add/rational'
Rational
(1, 3).to_json # => "{\"json_class\":\"Rational\",\"n\":1,\"d\":3}"
//}

@see JSON::Generator::GeneratorMethods::Hash#to_json...