Method: Flt::FormatBase.strict_epsilon
- Defined in:
- lib/float-formats/classes.rb
.strict_epsilon(sign = +1, round = nil) ⇒ Object
The strict epsilon is the smallest value that produces something different from 1.0 wehen added to 1.0. It may be smaller than the general epsilon, because of the particular rounding rules used with the floating point format. This is only meaningful when well-defined rules are used for rounding the result of floating-point addition. Note that (in pseudo-code):
((1.0+strict_epsilon)-1.0)==epsilon
TODO: use Flt::Num
767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 |
# File 'lib/float-formats/classes.rb', line 767 def self.strict_epsilon(sign=+1, round=nil) round ||= @round s = sign m = minimum_normalized_integral_significand e = 2*(1-significand_digits) # assume radix is even case @round when :down, :floor, :any_rounding, nil e = 2*(1-significand_digits) m = minimum_normalized_integral_significand when :half_even, :half_down e = 1-2*significand_digits m = 1 + radix_power(significand_digits)/2 when :half_up e = 1-2*significand_digits m = radix_power(significand_digits)/2 when :ceiling, :up, :up05 return min_value end return_value sign,m,e end |