Ruby 1.9.2 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > Floatクラス
クラスの継承リスト: Float < Numeric < Comparable < Object < Kernel < BasicObject
浮動小数点数のクラス。Float の実装は C 言語の double で、その精度は環 境に依存します。
一般にはせいぜい15桁です。詳しくは多くのシステムで採用されている 浮動小数点標準規格、IEEE (Institute of Electrical and Electronics Engineers: 米国電気電子技術者協会) 754 を参照してください。
# あるシステムでの 1/3(=0.333...) の結果 printf("%.50f\n", 1.0/3) => 0.33333333333333331482961625624739099293947219848633
Math::PI など、浮動小数点演算に関する定数については Math を 参照のこと。
定義 | 説明 | |
---|---|---|
self % other -> Float
|
算術演算子。剰余を計算します。 |
|
self * other -> Float
|
算術演算子。積を計算します。 |
|
self ** other -> Float
|
算術演算子。冪を計算します。 |
|
self + other -> Float
|
算術演算子。和を計算します。 |
|
self - other -> Float
|
算術演算子。差を計算します。 |
|
self / other -> Float
|
算術演算子。商を計算します。 |
|
self < other -> bool
|
比較演算子。数値として小さいか判定します。 |
|
self <= other -> bool
|
比較演算子。数値として等しいまたは小さいか判定します。 |
|
self <=> other -> nil | 1 | 0 | -1
|
self と other を比較して、self が大きい時に正、 等しい時に 0、小さい時に負の整数を返します。 比較できない場合はnilを返します |
|
self == other -> bool
|
比較演算子。数値として等しいか判定します。 |
|
self > other -> bool
|
比較演算子。数値として大きいか判定します。 |
|
self >= other -> bool
|
比較演算子。数値として等しいまたは大きいか判定します。 |
|
abs -> Float
|
自身の絶対値を返します。 |
|
ceil -> Integer
|
自身と等しいかより大きな整数のうち最小のものを返します。 |
|
denominator -> Integer
|
自身を Rational に変換した時の分母を返します。 |
|
divmod(other) -> [Numeric]
|
self を other で割った商 q と余り r を、 [q, r] という 2 要素の配列にして返します。 商 q は常に整数ですが、余り r は整数であるとは限りません。 |
|
eql?(other) -> bool
|
自身と other のクラスが等しくかつ == メソッドで比較して等しい場合に true を返します。 そうでない場合に false を返します。 |
|
finite? -> bool
|
数値が ∞, -∞, あるいは NaN でない場合に true を返します。 そうでない場合に false を返します。 |
|
floor -> Integer
|
自身と等しいかより小さな整数のうち最大のものを返します。 |
|
hash -> Fixnum
|
ハッシュ値を返します。 |
|
infinite? -> 1 | -1 | nil
|
数値が +∞ のとき 1、-∞のとき -1 を返します。それ以外は nil を返 します。 |
|
nan? -> bool
|
数値が NaN(Not a number)のとき真を返します。 |
|
numerator -> Integer
|
自身を Rational に変換した時の分子を返します。 |
|
rationalize -> Rational
|
自身から eps で指定した許容誤差の範囲に収まるような Rational を返 します。 |
|
round -> Fixnum
|
自身ともっとも近い整数を返します。 |
|
to_f -> self
|
self を返します。 |
|
to_i -> Integer
|
小数点以下を切り捨てて値を整数に変換します。 |
|
to_r -> Rational
|
自身を Rational に変換します。 |
|
to_s -> String
|
自身を人間が読みやすい形の文字列表現にして返します。 |
|
zero? -> bool
|
自身がゼロの時、真を返します。そうでない場合は false を返します。 |
定義 | 説明 | |
---|---|---|
DIG -> Fixnum
|
Float が表現できる最大の 10 進桁数 |
|
EPSILON -> Float
|
1.0 + Float::EPSILON != 1.0 となる最小の値 |
|
INFINITY -> Float
|
正の無限大 Infinity |
|
MANT_DIG -> Fixnum
|
仮数部の Float::RADIX 進法での桁数 |
|
MAX -> Float
|
Float が取り得る最大値 |
|
MAX_10_EXP -> Fixnum
|
最大の 10 進の指数 |
|
MAX_EXP -> Fixnum
|
最大の Float::RADIX 進の指数 |
|
MIN -> Float
|
Float が取り得る最小値 |
|
MIN_10_EXP -> Fixnum
|
最小の 10 進の指数 |
|
MIN_EXP -> Fixnum
|
最小の Float::RADIX 進の指数 |
|
NAN -> Float
|
NaN(Not a number) |
|
RADIX -> Fixnum
|
指数表現の基数 |
|
ROUNDS -> Fixnum
|
丸めモード (-1: 不定、0: 0.0 の方向に丸め、1: 四捨五入、2:正の無限 大の方向に丸め、3:負の無限大の方向に丸め) |
!
!=
+@
-@
clone
coerce
div
fdiv
i
integer?
nonzero?
real?
remainder
step
to_int
===
=~
__id__
__send__
_dump
class
dclone
display
enum_for
equal?
extend
freeze
frozen?
initialize
initialize_copy
inspect
instance_eval
instance_exec
instance_of?
instance_variable_defined?
instance_variable_get
instance_variable_set
instance_variables
is_a?
marshal_dump
marshal_load
method
method_missing
methods
must_be
must_be_close_to
must_be_empty
must_be_instance_of
must_be_kind_of
must_be_nil
must_be_same_as
must_be_within_epsilon
must_equal
must_include
must_match
must_raise
must_respond_to
must_send
must_throw
nil?
pretty_inspect
pretty_print
pretty_print_cycle
pretty_print_inspect
pretty_print_instance_variables
private_methods
protected_methods
public_methods
remove_instance_variable
respond_to?
respond_to_missing?
singleton_class
singleton_method_added
singleton_method_removed
singleton_method_undefined
singleton_methods
taint
tainted?
tap
to_a
to_ary
to_hash
to_io
to_proc
to_regexp
to_str
to_yaml
to_yaml_properties
to_yaml_style
trust
untaint
untrust
untrusted?
wont_be
wont_be_close_to
wont_be_empty
wont_be_instance_of
wont_be_kind_of
wont_be_nil
wont_be_same_as
wont_be_within_epsilon
wont_equal
wont_include
wont_match
wont_respond_to
.new
定義 | 説明 | ライブラリ |
---|---|---|
to_d -> BigDecimal
|
自身を BigDecimal に変換します。 |
bigdecimal/util |