Class: Float

Inherits:
Object show all
Includes:
ValueType
Defined in:
dragon/numeric.rb

Instance Method Summary collapse

Instance Method Details

#*(other) ⇒ Object


710
711
712
713
714
715
# File 'dragon/numeric.rb', line 710

def * other
  return nil unless other
  super
rescue Exception => e
  __raise_arithmetic_exception__ other, :*, e
end

#+(other) ⇒ Object


703
704
705
706
707
708
# File 'dragon/numeric.rb', line 703

def + other
  return nil unless other
  super
rescue Exception => e
  __raise_arithmetic_exception__ other, :+, e
end

#-(other) ⇒ Object


696
697
698
699
700
701
# File 'dragon/numeric.rb', line 696

def - other
  return nil unless other
  super
rescue Exception => e
  __raise_arithmetic_exception__ other, :-, e
end

#/(other) ⇒ Object


717
718
719
720
721
722
# File 'dragon/numeric.rb', line 717

def / other
  return nil unless other
  super
rescue Exception => e
  __raise_arithmetic_exception__ other, :/, e
end

#__original_add__Object


691
# File 'dragon/numeric.rb', line 691

alias_method :__original_add__,      :+

#__original_divide__Object


694
# File 'dragon/numeric.rb', line 694

alias_method :__original_divide__,   :-

#__original_multiply__Object


693
# File 'dragon/numeric.rb', line 693

alias_method :__original_multiply__, :*

#__original_subtract__Object


692
# File 'dragon/numeric.rb', line 692

alias_method :__original_subtract__, :-

#ifloor(int) ⇒ Object


746
747
748
# File 'dragon/numeric.rb', line 746

def ifloor int
  (self.idiv int.to_i) * int.to_i
end

#replace_infinity(scalar) ⇒ Object


735
736
737
738
739
740
# File 'dragon/numeric.rb', line 735

def replace_infinity scalar
  return self if !scalar
  return self unless self.infinite?
  return -scalar if self < 0
  return  scalar if self > 0
end

#serializeObject


724
725
726
# File 'dragon/numeric.rb', line 724

def serialize
  self
end

#signObject


729
730
731
732
733
# File 'dragon/numeric.rb', line 729

def sign
  return -1 if self < 0
  return  1 if self > 0
  return  0
end

#to_sfObject


742
743
744
# File 'dragon/numeric.rb', line 742

def to_sf
  "%.2f" % self
end