Class: Flt::SigDecimalsTolerance

Inherits:
FloatingTolerance show all
Defined in:
lib/flt/tolerance.rb

Overview

Implementation of (floating) tolerances given in number of significant decimal digits

Instance Method Summary (collapse)

Methods inherited from FloatingTolerance

float_minimum_normalized_fraction, ref_adjusted_exp, #relative_to_many

Methods inherited from Tolerance

#[], big_epsilon, bits, #cast_value, decimals, define_sugar, #descr_value, digits, epsilon, #eq?, #equal_to?, #greater_than?, #gt?, #integer, #integer?, #less_than?, #lt?, #relative_to, #relative_to_many, #seq?, #value, #zero?

Constructor Details

- (SigDecimalsTolerance) initialize(ndec, rounded = true)

Returns a new instance of SigDecimalsTolerance



449
450
451
452
453
# File 'lib/flt/tolerance.rb', line 449

def initialize(ndec, rounded = true)
  super Tolerance.decimals(ndec, rounded), 10
  @decimals = ndec
  @rounded = rounded
end

Instance Method Details

- (Object) to_s



454
455
456
# File 'lib/flt/tolerance.rb', line 454

def to_s
  "#{@decimals} sig. #{@rounded ? 'r.' : 'r'}dec."
end