Class: Flt::SigBitsTolerance

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

Overview

Implementation of (floating) tolerances given in number of significant bits

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

#initialize(ndec, rounded = true) ⇒ SigBitsTolerance


473
474
475
476
477
# File 'lib/flt/tolerance.rb', line 473

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

Instance Method Details

#to_sObject


478
479
480
# File 'lib/flt/tolerance.rb', line 478

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