Class: Float

Inherits:
Object show all
Defined in:
lib/ext/float.rb

Overview

Copyright © 2012 by Tim Felgentreff

Instance Method Summary collapse

Instance Method Details

#cl_approx(float) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/ext/float.rb', line 4

def cl_approx(float)
  # Answer true if I am approximately equal to the argument
  epsilon = Cassowary::SimplexSolver::Epsilon
  if self == 0.0
    float.abs < epsilon
  elsif float == 0.0
    abs < epsilon
  else
    (self - float).abs < (abs * epsilon)
  end
end

#cl_approx_zeroObject



16
17
18
# File 'lib/ext/float.rb', line 16

def cl_approx_zero
  cl_approx 0.0
end

#definitely_negativeObject



20
21
22
23
# File 'lib/ext/float.rb', line 20

def definitely_negative
  # return true if I am definitely negative (i.e. smaller than negative epsilon)"
  self < (0.0 - Cassowary::SimplexSolver::Epsilon)
end