るりまサーチ

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

別のキーワード

  1. _builtin to_s
  2. openssl to_der
  3. openssl to_s
  4. _builtin to_a
  5. openssl to_pem

ライブラリ

クラス

キーワード

検索結果

<< < 1 2 3 4 > >>

Time#tv_sec -> Integer (109.0)

起算時からの経過秒数を整数で返します。

...起算時からの経過秒数を整数で返します。

//emlist[][ruby]{
t = Time.local(2000,1,2,3,4,5,6)
p t # => 2000-01-02 03:04:05 +0900
p "%10.6f" % t.to_f # => "946749845.000006"
p t.to_i # => 946749845
p t.tv_sec # => 946749845
//}...

Time#tv_usec -> Integer (109.0)

時刻のマイクロ秒の部分を整数で返します。

...時刻のマイクロ秒の部分を整数で返します。

//emlist[][ruby]{
t = Time.local(2000,1,2,3,4,5,6)
p "%10.6f" % t.to_f #=> "946749845.000006"
p t.usec #=> 6
//}...

Time#usec -> Integer (109.0)

時刻のマイクロ秒の部分を整数で返します。

...時刻のマイクロ秒の部分を整数で返します。

//emlist[][ruby]{
t = Time.local(2000,1,2,3,4,5,6)
p "%10.6f" % t.to_f #=> "946749845.000006"
p t.usec #=> 6
//}...

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

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

...近い整
数か 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, R...

Rational#floor(precision = 0) -> Integer | Rational (108.0)

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

...い整
数か Rational を返します。

//emlist[例][ruby]{
Rational('-123.456').floor(+1) # => (-247/2)
Rational('-123.456').floor(+1).to_f # => -123.5
Rational('-123.456').floor(0) # => -124
Rational('-123.456').floor(-1) # => -130
//}

@see Rational#ceil, Rational#round, R...

絞り込み条件を変える

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

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

...近い整
数か 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) # => -1...

BigDecimal#round(n) -> BigDecimal (26.0)

クラスメソッド BigDecimal.mode(BigDecimal::ROUND_MODE,flag) で指定した BigDecimal::ROUND_MODE に従って丸め操作を実行します。

...に少なくとも n 個の 0 が並びます)。

//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").round(4).to_f # => 1.2346
BigDecimal("15.23456").round(-1).to_f # => 20.0
//}

2番目の引数を指定すると、BigDecimal.mode の指定を無視して、指定さ
れた方法で...
...丸め操作を実行します。

//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").round(3,BigDecimal::ROUND_HALF_EVEN).to_f # => 1.235
require "bigdecimal"
BigDecimal("1.23356").round(3,BigDecimal::ROUND_HALF_EVEN).to_f # => 1.234
//}

@see BigDecimal.mode...

BigDecimal#round(n, b) -> BigDecimal (26.0)

クラスメソッド BigDecimal.mode(BigDecimal::ROUND_MODE,flag) で指定した BigDecimal::ROUND_MODE に従って丸め操作を実行します。

...に少なくとも n 個の 0 が並びます)。

//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").round(4).to_f # => 1.2346
BigDecimal("15.23456").round(-1).to_f # => 20.0
//}

2番目の引数を指定すると、BigDecimal.mode の指定を無視して、指定さ
れた方法で...
...丸め操作を実行します。

//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").round(3,BigDecimal::ROUND_HALF_EVEN).to_f # => 1.235
require "bigdecimal"
BigDecimal("1.23356").round(3,BigDecimal::ROUND_HALF_EVEN).to_f # => 1.234
//}

@see BigDecimal.mode...

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

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

...て下さい。


//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
end
//}

数値クラスの算術演算子は通常自分と演算...
...んでいます。

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

def + (a)
if a.kind_of?(Rational)
# 長いので省略
elsif a.kind_of?(Integer)
# 長いので省略
elsif a.kind_of?(Float)
Float(self) + a
else
x, y = a.coerce(self)
x + y
end
end
//}

@param other...
<< < 1 2 3 4 > >>