るりまサーチ

最速Rubyリファレンスマニュアル検索!
58件ヒット [1-58件を表示] (0.031秒)
トップページ > クエリ:self[x] > クエリ:to_f[x] > ライブラリ:ビルトイン[x]

別のキーワード

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

クラス

キーワード

検索結果

Float#to_f -> self (18226.0)

self を返します。

...self を返します。

//emlist[例][ruby]{
3.14.to_f # => 3.14
//}...

Integer#to_f -> Float (18143.0)

self を浮動小数点数(Float)に変換します。

...
self
を浮動小数点数(Float)に変換します。

self
が Float の範囲に収まらない場合、Float::INFINITY を返します。

//emlist[][ruby]{
1.to_f # => 1.0
(Float::MAX.to_i * 2).to_f # => Infinity
(-Float::MAX.to_i * 2).to_f # => -Infinity
//}...

Numeric (62.0)

数値を表す抽象クラスです。Integer や Float などの数値クラス は Numeric のサブクラスとして実装されています。

...- - - -
to_c | o - - - - - o
to_f
| - - o o o o o
to_i | - o -...
...**d
if self > 0
self
.quo(x).ceil * x
else
self
.quo(x).floor * x
end
end

def rounddown(d=0)
x = 10**d
if self < 0
self
.quo(x).ceil * x
else
self
.quo(x).floor * x
end
end

def roundoff(d=0)
x = 10**d
if self < 0
(self.quo(x) -...
...0.5).ceil * x
else
(self.quo(x) + 0.5).floor * x
end
end
end
//}...
...times | - o - - -
to_c | o - - - o
to_f
| - o o o o
Numeric Integer Float Rational Complex
-...

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

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

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

デフォルトでは self と other を Float に変換して [other, self] という配列にして返します。
Numeric のサブクラスは、このメソ...
...//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
//}

数値クラスの算術演算子は通常自分と演算できないクラ...
...b/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 オペランドを数値で指定します。...

Bignum#eql?(other) -> bool (36.0)

self と other のクラスが等しくかつ同じ値である場合に true を返します。 そうでない場合に false を返します。

...
self
と other のクラスが等しくかつ同じ値である場合に true を返します。
そうでない場合に false を返します。

@param other self と比較したい数値。

(1 << 64) == (1 << 64).to_f # => true
(1 << 64).eql?((1 << 64).to_f) # => false...

絞り込み条件を変える

String#hex -> Integer (14.0)

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

...とアンダースコアは無視されます。
文字列が [_0-9a-fA-F] 以外の文字を含むときはその文字以降を無視します。

self
が空文字列のときは 0 を返します。

//emlist[例][ruby]{
p "10".hex # => 16
p "ff".hex # => 255
p "0x10".hex # => 16
p "-0x10...