るりまサーチ

最速Rubyリファレンスマニュアル検索!
420件ヒット [201-300件を表示] (0.048秒)

別のキーワード

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

ライブラリ

クラス

キーワード

検索結果

<< < 1 2 3 4 5 > >>

BigDecimal#floor -> Integer (37.0)

self 以下の最大整数を返します。

...self 以下の最大整数を返します。

@param n 小数点以下の桁数を整数で指定します。

//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").floor # => 1
BigDecimal("-1.23456").floor # => -2
//}

以下のように引数 n を与えることもできます。
n >=...
...にします)。
n が負のときは小数点以上 n 桁目を操作します
(小数点位置から左に少なくとも n 個の 0 が並びます)。

//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").floor(4).to_f # => 1.2345
BigDecimal("15.23456").floor(-1).to_f # => 10.0
//}...

BigDecimal#floor(n) -> BigDecimal (37.0)

self 以下の最大整数を返します。

...self 以下の最大整数を返します。

@param n 小数点以下の桁数を整数で指定します。

//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").floor # => 1
BigDecimal("-1.23456").floor # => -2
//}

以下のように引数 n を与えることもできます。
n >=...
...にします)。
n が負のときは小数点以上 n 桁目を操作します
(小数点位置から左に少なくとも n 個の 0 が並びます)。

//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").floor(4).to_f # => 1.2345
BigDecimal("15.23456").floor(-1).to_f # => 10.0
//}...

BigDecimal#split -> [Integer, String, Integer, Integer] (37.0)

BigDecimal 値を 0.xxxxxxx*10**n と表現したときに、 符号 (NaNのときは 0、それ以外は+1か-1になります)、 仮数部分の文字列("xxxxxxx")と、基数(10)、更に指数 n を配列で返します。

...st[][ruby]{
require "bigdecimal"
a = BigDecimal("3.14159265")
f, x, y, z = a.split
//}

とすると、f = 1、x = "314159265"、y = 10、z = 1 になります。
従って、以下のようにする事で Float に変換することができます。

//emlist[][ruby]{
s = "0."+x
b = f*(s.to_f)*(y*...
...*z)
//}

@see BigDecimal#to_f...

Numeric#coerce(other) -> [Numeric] (31.0)

自身と other が同じクラスになるよう、自身か other を変換し [other, self] という配列にして返します。

...であった場合、
super を呼んでいることに注意して下さい。


//emlist[例][ruby]{
# lib/rational.rb より

def coerce(other)
if other.kind_of?(Float)
return other, self.to_f
elsif other.kind_of?(Integer)
return Rational.new!(other, 1), self
else
super
end
en...
...らない数値クラスである場合、引数の coerce により自身を変換してから
+ 演算子を呼んでいます。

//emlist[例][ruby]{
# lib/rational.rb より

def + (a)
if a.kind_of?(Rational)
# 長いので省略
elsif a.kind_of?(Integer)
# 長いので省略
elsi...

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

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

...す。

//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#round(precision = 0) -> Integer | Rational (31.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_i -> Integer (31.0)

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

...[例][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
//}

precision を指定した場合は指定した桁数で切り捨てた整数か
Rational を返します。

//emlist[例][ruby]{
Rat...
...ional('-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 (31.0)

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

...[例][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
//}

precision を指定した場合は指定した桁数で切り捨てた整数か
Rational を返します。

//emlist[例][ruby]{
Rat...
...ional('-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...

BigDecimal#truncate -> Integer (25.0)

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

...ます)。
n が負のときは小数点以上 n 桁目を操作します
(小数点位置から左に少なくとも n 個の 0 が並びます)。

//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").truncate(4).to_f # => 1.2345
BigDecimal("15.23456").truncate(-1).to_f # => 10.0
//}...
<< < 1 2 3 4 5 > >>