-
Notifications
You must be signed in to change notification settings - Fork 1
Add named math constants (PI, E, TAU) #105
Copy link
Copy link
Open
Description
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 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels