るりまサーチ

最速Rubyリファレンスマニュアル検索!
352件ヒット [101-200件を表示] (0.184秒)
トップページ > クエリ:I[x] > クエリ:t[x] > クラス:Rational[x] > クエリ:-[x]

別のキーワード

  1. _builtin to_i
  2. fiddle to_i
  3. matrix elements_to_i
  4. matrix i
  5. csv to_i

ライブラリ

キーワード

検索結果

<< < 1 2 3 4 > >>

Rational#truncate(precision = 0) -> Rational | Integer (9356.0)

小数点以下を切り捨てて値を整数に変換します。

...ision 計算結果の精度

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

//emlist[例][ruby]{
Rational
(2, 3).to_i # => 0
Rational
(3).to_i # => 3
Rational
(300.6).to_i # => 300
Rational
(98, 71).to_i # => 1
Rational
(-31, 2).to_i # => -15
//}

precisi...
...
Rational
を返します。

//emlist[例][ruby]{
Rational
('-123.456').truncate(+1) # => (-617/5)
Rational
('-123.456').truncate(+1).to_f # => -123.4
Rational
('-123.456').truncate(0) # => -123
Rational
('-123.456').truncate(-1) # => -120
//}

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

Rational#ceil(precision = 0) -> Integer | Rational (9325.0)

自身と等しいかより大きな整数のうち最小のものを返します。

...を返します。

@param precision 計算結果の精度

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

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

precision を指定した場合は指...
... Rational を返します。

//emlist[例][ruby]{
Rational
('-123.456').ceil(+1) # => (-617/5)
Rational
('-123.456').ceil(+1).to_f # => -123.4
Rational
('-123.456').ceil(0) # => -123
Rational
('-123.456').ceil(-1) # => -120
//}

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

Rational#numerator -> Integer (9319.0)

分子を返します。

...分子を返します。

@return 分子を返します。

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

@see Rational#denominator...

Rational#convert(*arg) -> Rational (9301.0)

引数を有理数(Rational)に変換した結果を返します。

...引数を有理数(Rational)に変換した結果を返します。

@param arg 変換対象のオブジェクトです。

Kernel.#Rational の本体です。

@see Kernel.#Rational...

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

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

...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#to_json(*args) -> String (9301.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...
...Generator::GeneratorMethods::Hash#to_json を呼び出しています。

@param args 引数はそのまま JSON::Generator::GeneratorMethods::Hash#to_json
に渡されます。

//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...

Rational#to_r -> Rational (9301.0)

自身を返します。

...自身を返します。

@return 自身を返します。

//emlist[例][ruby]{
Rational
(3, 4).to_r # => (3/4)
Rational
(8).to_r # => (8/1)
//}...

Rational#to_s -> String (9301.0)

自身を人間が読みやすい形の文字列表現にして返します。

..."-17/7" のように10進数の表記を返します。

@return 有理数の表記にした文字列を返します。

//emlist[例][ruby]{
Rational
(3, 4).to_s # => "3/4"
Rational
(8).to_s # => "8/1"
Rational
(-8, 6).to_s # => "-4/3"
Rational
(0.5).to_s # => "1/2"
//}

@see Rational#inspect...

Rational.json_create(hash) -> Rational (9301.0)

JSON のオブジェクトから Rational のオブジェクトを生成して返します。

...JSON のオブジェクトから Rational のオブジェクトを生成して返します。

@param hash 分子をキー 'n'、分母をキー 'd' に持つハッシュを指定します。...

Rational#to_f -> Float (9219.0)

自身の値を最も良く表現する Float に変換します。

...Float に変換します。

絶対値が極端に小さい、または大きい場合にはゼロや無限大が返ることがあります。

@return Float を返します。

//emlist[例][ruby]{
Rational
(2).to_f # => 2.0
Rational
(9, 4).to_f # => 2.25
Rational
(-3, 4).to_f...
...# => -0.75
Rational
(20, 3).to_f # => 6.666666666666667
Rational
(1, 10**1000).to_f # => 0.0
Rational
(-1, 10**1000).to_f # => -0.0
Rational
(10**1000).to_f # => Infinity
Rational
(-10**1000).to_f # => -Infinity
//}...

絞り込み条件を変える

<< < 1 2 3 4 > >>