Class: Flt::DecimalsTolerance

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

Overview

Implementation of (absolute) tolerances given in number of decimal digits

Instance Method Summary collapse

Methods inherited from AbsoluteTolerance

#relative_to, #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

#initialize(ndec, rounded = true) ⇒ DecimalsTolerance

Returns a new instance of DecimalsTolerance.



461
462
463
464
465
# File 'lib/flt/tolerance.rb', line 461

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

Instance Method Details

#to_sObject



466
467
468
# File 'lib/flt/tolerance.rb', line 466

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