るりまサーチ

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

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

Rational#-(other) -> Rational | Float (21232.0)

差を計算します。

...差を計算します。

@
param other 自身から引く数

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

//emlist[例][ruby]{
r = Rational(3, 4)
r - 1 # => (-1/4)
r - 0.5 # => 0.25
//}...

Rational#-@ -> Rational (15336.0)

単項演算子の - です。 self の符号を反転させたものを返します。

...単項演算子の - です。
self の符号を反転させたものを返します。

//emlist[例][ruby]{
r = Rational(3, 4)
-
r # => (-3/4)
//}...

Rational#rationalize(eps = 0) -> Rational (9320.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#negative? -> bool (9220.0)

self が 0 未満の場合に true を返します。そうでない場合に false を返します。

...self が 0 未満の場合に true を返します。そうでない場合に false を返します。

//emlist[例][ruby]{
Rational
(1, 2).negative? # => false
Rational
(-1, 2).negative? # => true
//}

@
see Rational#positive?...

Rational#positive? -> bool (9220.0)

self が 0 より大きい場合に true を返します。そうでない場合に false を返します。

...self が 0 より大きい場合に true を返します。そうでない場合に false を返します。

//emlist[例][ruby]{
Rational
(1, 2).positive? # => true
Rational
(-1, 2).positive? # => false
//}

@
see Rational#negative?...

絞り込み条件を変える

Rational#to_i -> Integer (6268.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 # => -15...
...
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#truncate(precision = 0) -> Rational | Integer (6268.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 # => -15...
...
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#numerator -> Integer (6244.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#denominator -> Integer (6238.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#to_f -> Float (6238.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 ... > >>