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
56
57
58
59
//! # Number Constants and Utilities
//!
//! This module provides fundamental mathematical constants and number manipulation utilities.
/// Machine epsilon for f64 precision
///
/// The smallest representable positive number such that 1.0 + EPSILON != 1.0
///
/// # Examples
///
/// ```rust
/// use sophy::base::numbers::EPSILON;
///
/// assert!(EPSILON > 0.0);
/// assert!(1.0 + EPSILON != 1.0);
/// ```
pub const EPSILON: f64 = f64EPSILON;
/// The mathematical constant π (pi)
///
/// The ratio of a circle's circumference to its diameter
///
/// # Examples
///
/// ```rust
/// use sophy::base::numbers::PI;
///
/// let circumference = 2.0 * PI * 5.0; // radius = 5
/// assert!((circumference - 31.415926535897932).abs() < 1e-15);
/// ```
pub const PI: f64 = PI;
/// Euler's number (e)
///
/// The base of the natural logarithm
///
/// # Examples
///
/// ```rust
/// use sophy::base::numbers::EULER;
///
/// // e^1 should equal EULER, and ln(e) should equal 1
/// assert!((EULER.ln() - 1.0).abs() < 1e-15);
/// ```
pub const EULER: f64 = E;
/// The golden ratio (φ)
///
/// The golden ratio (1 + √5) / 2 ≈ 1.618033988749895
///
/// # Examples
///
/// ```rust
/// use sophy::base::numbers::PHI;
///
/// // φ² = φ + 1
/// assert!((PHI * PHI - (PHI + 1.0)).abs() < 1e-15);
/// ```
pub const PHI: f64 = 1.618033988749895;