Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated whitestone.markdown

  • Loading branch information...
commit f43587f5d825fe6c525fb139414c503f96d1befb 1 parent 42692b2
Gavin Sinclair authored
Showing with 15 additions and 7 deletions.
  1. +15 −7 whitestone.markdown
22 whitestone.markdown
View
@@ -173,13 +173,18 @@ Nonetheless, it serves to demonstrate the kind of output Whitestone produces.
Ko (1..10), Enumerable
Ft Float Asserts a float is "essentially" equal to its expected value
- Ft FLOAT, FLOAT [, EPSILON]
- Ft Math::PI, 3.14159265
- Ft Math::PI, 3.14 # will fail
- Ft Math::PI, 3.14, 0.1 # will pass
- The comparison used is relative, not absolute. The
- difference divided by the expected value must be less
- than 'epsilon' (default 0.000001).
+ Ft FLOAT, FLOAT
+ Ft (0.2 + 0.1), 0.3
+ # Note that 0.2 + 0.1 == 0.3 is false, due to the
+ # inaccurate representation of floats (IEEE 754).
+ Float equality is based on ratio, not difference, so
+ that it works at any scale. Here is a simplified
+ definition:
+ def essentially_equal?(a,b)
+ (a/b - 1).abs < 1e-13
+ end
+ If one of the numbers is zero, then ratio doesn't work,
+ so that case is treated specially. See http://bit.ly/wBvbgi
Id Identity Asserts two objects have the same object_id
Id OBJECT, OBJECT
@@ -797,6 +802,9 @@ They are hardcoded and it would be a major effort to customise them!
* July 2010: originally developed under the name 'attest' but not released
* 2 JAN 2012: version 1.0.0
* 2 JAN 2012: version 1.0.1 with corrected README.txt
+* 27 JAN 2012: version 1.0.2 with improved implementation and testing of float
+ equality (Ft). Note slight backwards incompatibility: Ft no longer accepts
+ 'epsilon' argument.
### Future plans
Please sign in to comment.
Something went wrong with that request. Please try again.