1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
extern crate num;
use Float;
/// The default epsilon value used for floating point comparisons.
pub static EPSILON:f64 = 1.0E-8;
/// almost_equal tells if the two floating-point values x and y are considered
/// equal within the specified absolute == relative tolerence value.
///
/// This method of comparison used is described online at:
///
/// http://realtimecollisiondetection.net/blog/?p=89
///
/// Also see is_equal which uses a predefined EPSILON value for tolerence.
///
/// # Examples
///
/// ```
/// assert!(fiz_math::almost_equal(0.9, 1.0, 0.1000001));
/// assert!(fiz_math::almost_equal(0.9, 1.0, 0.1));
/// ```
/// equal tells if the two floating-point values x and y are considered equal
/// within the EPSILON absolute == relative tolerence value, via is_almost_equal.
///
/// # Examples
///
/// ```
/// use fiz_math::equal;
///
/// assert!(fiz_math::equal(1.00000001, 1.0));
/// assert!(fiz_math::equal(1.0, 1.0));
/// assert!(!fiz_math::equal(0.9, 1.0));
/// ```