るりまサーチ

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

別のキーワード

  1. openssl t61string
  2. asn1 t61string
  3. matrix t
  4. t61string new
  5. fiddle type_size_t

ライブラリ

キーワード

検索結果

<< 1 2 3 > >>

Rational#rationalize(eps = 0) -> Rational (9208.0)

自身から eps で指定した許容誤差の範囲に収まるような Rational を返 します。

... Rational を返
します。

eps を省略した場合は self を返します。

@param eps 許容する誤差

//emlist[例][ruby]{
r = Rational(5033165, 16777216)
r.rationalize # => (5033165/16777216)
r.rationalize(Rational(0.01)) # => (3/10)
r.rationalize(Rational(0.1))...

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

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

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

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

Kernel.#Rational の本体です。

@see Kernel.#Rational...

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

自身を BigDecimal に変換します。

...@param nFig 計算を行う桁数

@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(1...

Rational#to_i -> Integer (6108.0)

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

...

@param precision 計算結果の精度

@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 # =>...
...
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#to_json(*args) -> String (6108.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#truncate(precision = 0) -> Rational | Integer (6108.0)

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

...

@param precision 計算結果の精度

@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 # =>...
...
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#*(other) -> Rational | Float (3108.0)

積を計算します。

...します。

@param other 自身に掛ける数

other に Float を指定した場合は、計算結果を Float で返しま
す。

//emlist[例][ruby]{
r = Rational(3, 4)
r * 2 # => (3/2)
r * 4 # => (3/1)
r * 0.5 # => 0.375
r * Rational(1, 2) # => (3...

Rational#**(other) -> Rational | Float (3108.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
//}...

Rational#+(other) -> Rational | Float (3108.0)

和を計算します。

...和を計算します。

@param other 自身に足す数

other に Float を指定した場合は、計算結果を Float で返しま
す。

//emlist[例][ruby]{
r = Rational(3, 4)
r + Rational(1, 2) # => (5/4)
r + 1 # => (7/4)
r + 0.5 # => 1.25
//}...
<< 1 2 3 > >>