Summary
The language currently has no named constants for common mathematical values. Users have to write magic number literals like 3.14159265358979... when working with trigonometry.
Proposed constants
PI (or pi) — π ≈ 3.141592653589793
E (or e) — Euler's number ≈ 2.718281828459045
TAU (or tau) — 2π ≈ 6.283185307179586
Inf — positive infinity (already exists as a float literal)
NaN — not-a-number (already exists as a float literal)
Motivation
Came up when writing tests for trig functions (023_trig_functions.ndc) — to test sin(pi/2) == 1.0 we had to inline 1.5707963267948966 as a magic number, which is fragile and unreadable.
Possible implementation
Register as global constants in ndc_stdlib/src/math.rs, similar to how NaN and Inf are likely handled.
Summary
The language currently has no named constants for common mathematical values. Users have to write magic number literals like
3.14159265358979...when working with trigonometry.Proposed constants
PI(orpi) — π ≈ 3.141592653589793E(ore) — Euler's number ≈ 2.718281828459045TAU(ortau) — 2π ≈ 6.283185307179586Inf— positive infinity (already exists as a float literal)NaN— not-a-number (already exists as a float literal)Motivation
Came up when writing tests for trig functions (
023_trig_functions.ndc) — to testsin(pi/2) == 1.0we had to inline1.5707963267948966as a magic number, which is fragile and unreadable.Possible implementation
Register as global constants in
ndc_stdlib/src/math.rs, similar to howNaNandInfare likely handled.