Files
sx/library/modules/math/math.sx
agra c027e1969b stdlib: relocate modules under library/
- examples/modules/ -> library/modules/ (top-level, no more
  symlink hacks in consumer projects)
- compiler discovers stdlib via _NSGetExecutablePath / readlink
  /proc/self/exe; searches dev layout (../../library), install
  layout (../library), and alongside-binary fallback
- SX_STDLIB_PATH env var overrides for tests / dev convenience
- SX_DEBUG_STDLIB env var dumps the discovery results
- build.zig installs library/ alongside the binary
- Compilation gains stdlib_paths field threaded through resolveImports
- 50 tests pass; consumer projects can now build from any cwd
2026-05-17 13:49:25 +03:00

38 lines
657 B
Plaintext

PI :f32: 3.14159265;
TAU :f32: 6.28318530;
DEG2RAD :f32: 0.01745329;
RAD2DEG :f32: 57.2957795;
sqrt :: (x: $T) -> T #builtin;
sin :: (x: $T) -> T #builtin;
cos :: (x: $T) -> T #builtin;
floor :: (x: $T) -> T #builtin;
min :: (a: $T, b: T) -> T {
if a < b then a else b;
}
max :: (a: $T, b: T) -> T {
if a > b then a else b;
}
clamp :: (val: $T, lo: T, hi: T) -> T {
if val < lo then lo
else if val > hi then hi
else val;
}
abs :: (x: $T) -> T {
if x < 0 then 0 - x else x;
}
lerp :: (a: f32, b: f32, t: f32) -> f32 {
a + (b - a) * t;
}
sign :: (x: $T) -> T {
if x > 0 then 1
else if x < 0 then 0 - 1
else 0;
}