0
@@ -19,102 +19,141 @@ class Float < Numeric
0
EPSILON = Platform::Float.EPSILON
0
def self.induced_from(obj)
0
- if [Float, Bignum, Fixnum].include?(obj.class)
0
+ when Float, Bignum, Fixnum
0
raise TypeError, "failed to convert #{obj.class} into Float"
0
+ return [other, self] if other.__kind_of__ Float
0
+ Ruby.primitive :float_uminus
0
+ # binary math operators
0
- return super(other) unless other.is_a?(Float)
0
- Platform::Float.add self, other
0
+ Ruby.primitive :float_add
0
+ b, a = math_coerce other
0
- return super(other) unless other.is_a?(Float)
0
- Platform::Float.sub self, other
0
+ Ruby.primitive :float_sub
0
+ b, a = math_coerce other
0
- return super(other) unless other.is_a?(Float)
0
- Platform::Float.mul self, other
0
+ Ruby.primitive :float_mul
0
+ b, a = math_coerce other
0
# see README-DEVELOPERS regarding safe math compiler plugin
0
- return super(other) unless other.is_a?(Float)
0
- Platform::Float.div self, other
0
+ Ruby.primitive :float_div
0
+ b, a = math_coerce other
0
alias_method :/, :divide
0
- Platform::Float.uminus self
0
+ Ruby.primitive :float_divmod
0
+ b, a = math_coerce other
0
- return super(other) unless other.is_a?(Float)
0
- Platform::Float.compare self, other
0
+ Ruby.primitive :float_pow
0
+ b, a = math_coerce other
0
- return super(other) unless other.is_a?(Float)
0
- Platform::Float.eql? self, other
0
+ return 0 / 0.to_f if other == 0
0
+ self.divmod(Float(other))[1]
0
+ alias_method :modulo, :%
0
- return false unless other.is_a?(Float)
0
- Platform::Float.eql? self, other
0
+ # comparison operators
0
+ Ruby.primitive :float_lt
0
+ b, a = math_coerce other, :compare_error
0
- raise FloatDomainError, "divide by 0" if other == 0
0
- return super(other) unless other.is_a?(Float)
0
- div = (self / other).floor;
0
- mod = Platform::Float.fmod self, other
0
+ Ruby.primitive :float_le
0
+ b, a = math_coerce other, :compare_error
0
+ Ruby.primitive :float_gt
0
+ b, a = math_coerce other, :compare_error
0
+ Ruby.primitive :float_ge
0
+ b, a = math_coerce other, :compare_error
0
+ Ruby.primitive :float_compare
0
+ b, a = math_coerce other, :compare_error
0
+ Ruby.primitive :float_equal
0
+ b, a = math_coerce(other)
0
- return [div.to_i, mod]
0
+ Ruby.primitive :float_eql
0
-
Platform::Float.nan? self0
+
Ruby.primitive :float_isnan0
-
Platform::Float.infinite? self
0
+
Ruby.primitive :float_isinf
0
not (nan? or infinite?)
0
- return super(other) unless other.is_a?(Float)
0
- Platform::Float.pow self, other
0
- raise FloatDomainError, self < 0 ? "-Infinity" : "Infinity"
0
- if self < Platform::Fixnum.MAX.to_f && self > Platform::Fixnum.MIN.to_f
0
- Platform::Float.to_i self
0
- Bignum.from_float self
0
+ Ruby.primitive :float_to_i
0
alias_method :to_int, :to_i
0
alias_method :truncate, :to_i
0
@@ -138,19 +177,7 @@ class Float < Numeric
0
private :to_s_formatted
0
- return 0 / 0.to_f if other == 0
0
- self.divmod(Float(other))[1]
0
- alias_method :modulo, :%
0
- if self < Platform::Fixnum.MAX.to_f && self > Platform::Fixnum.MIN.to_f
0
- Platform::Float.round self
0
- Bignum.from_float self
0
+ Ruby.primitive :float_round