るりまサーチ

最速Rubyリファレンスマニュアル検索!
273件ヒット [101-200件を表示] (0.046秒)

別のキーワード

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

クラス

キーワード

検索結果

<< < 1 2 3 > >>

Time#subsec -> Integer | Rational (15.0)

時刻を表す分数を返します。

...Rational を返す場合があります。

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

to_f
の値と subsec の値の下のほうの桁の値は異なる場合があります。
というのは IEEE 7...

Time#tv_nsec -> Integer (15.0)

時刻のナノ秒の部分を整数で返します。

...す。

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

IEEE 754 浮動小数点数で表現できる精度が違うため、Time#to_fの最小
の桁とnsecの最小の桁は異なります。nsecで表され...

File::Stat#ctime -> Time (9.0)

最終状態変更時刻を返します。 (状態の変更とは chmod などによるもので、Unix では i-node の変更を意味します)

...最終状態変更時刻を返します。
(状態の変更とは chmod などによるもので、Unix では i-node の変更を意味します)

//emlist[][ruby]{
fs = File::Stat.new($0)
#例
p fs.ctime.to_f #=> 1188719843.0
//}


@see Time...

Numeric#coerce(other) -> [Numeric] (9.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
//}

数値クラスの算術演算子は通常...

Rational#ceil(precision = 0) -> Integer | Rational (9.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 (9.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 (9.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...

Rational#to_i -> Integer (9.0)

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

...整数か
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#...

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

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

...整数か
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#...

String#hex -> Integer (9.0)

文字列に 16 進数で数値が表現されていると解釈して整数に変換します。 接頭辞 "0x", "0X" とアンダースコアは無視されます。 文字列が [_0-9a-fA-F] 以外の文字を含むときはその文字以降を無視します。

...x10".hex # => -16

p "xyz".hex # => 0
p "10z".hex # => 16
p "1_0".hex # => 16

p "".hex # => 0
//}

@see String#oct, String#to_i, String#to_f,
Kernel.#Integer, Kernel.#Float

このメソッドの逆に数値を文字列に変換するには
Kernel.#sprintf, String#%,
Integer#to_s...

絞り込み条件を変える

<< < 1 2 3 > >>