runmat_runtime/builtins/constants/
mod.rs

1//! Global constants registered into the runtime (variables, not functions).
2//! This replaces legacy registrations in `src/constants.rs`.
3
4use runmat_builtins::Value;
5
6// Numeric constants
7runmat_builtins::inventory::submit! {
8    runmat_builtins::Constant { name: "pi", value: Value::Num(std::f64::consts::PI) }
9}
10
11runmat_builtins::inventory::submit! {
12    runmat_builtins::Constant { name: "e", value: Value::Num(std::f64::consts::E) }
13}
14
15runmat_builtins::inventory::submit! {
16    runmat_builtins::Constant { name: "eps", value: Value::Num(f64::EPSILON) }
17}
18
19runmat_builtins::inventory::submit! {
20    runmat_builtins::Constant { name: "sqrt2", value: Value::Num(std::f64::consts::SQRT_2) }
21}
22
23runmat_builtins::inventory::submit! {
24    runmat_builtins::Constant { name: "i", value: Value::Complex(0.0, 1.0) }
25}
26
27runmat_builtins::inventory::submit! {
28    runmat_builtins::Constant { name: "j", value: Value::Complex(0.0, 1.0) }
29}
30
31// Infinity and NaN (both lowercase and MATLAB-style capitalised names)
32runmat_builtins::inventory::submit! {
33    runmat_builtins::Constant { name: "inf", value: Value::Num(f64::INFINITY) }
34}
35
36runmat_builtins::inventory::submit! {
37    runmat_builtins::Constant { name: "Inf", value: Value::Num(f64::INFINITY) }
38}
39
40runmat_builtins::inventory::submit! {
41    runmat_builtins::Constant { name: "nan", value: Value::Num(f64::NAN) }
42}
43
44runmat_builtins::inventory::submit! {
45    runmat_builtins::Constant { name: "NaN", value: Value::Num(f64::NAN) }
46}
47
48// Logical constants
49runmat_builtins::inventory::submit! {
50    runmat_builtins::Constant { name: "true", value: Value::Bool(true) }
51}
52
53runmat_builtins::inventory::submit! {
54    runmat_builtins::Constant { name: "false", value: Value::Bool(false) }
55}