ludic/docs/language/builtins/fn-fixed.md
Orkuncakilkaya 2e0047514b refactor(lang): rename builtins flr->floor and fx->fixed
De-abbreviate the two bare fixed-point conversion builtins:
  flr(f) -> int     ->  floor(f) -> int    (fixed -> int, flooring)
  fx(i)  -> fixed   ->  fixed(i) -> fixed  (int -> fixed; mirrors how the
                                            stringify builtin is `string`)

Updates the compiler dispatch, all call sites, the grammars/LSP/JetBrains
tokens, and the docs (fn-flr -> fn-floor, fn-fx -> fn-fixed). Reseeded;
C-free fixpoint holds; all suites green (45/24/29); site + check.py OK.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-30 02:01:56 +03:00

982 B

id name category kind tokens sig tip order
fn-fixed fixed builtins builtin fixed fixed(n) -> fixed Lift an integer into a Q16.16 fixed-point value. 50

Converts an integer into a fixed value (Ludic's Q16.16 fixed-point type), so it can take part in fractional arithmetic. Ludic has no floating point; fixed is how you carry sub-pixel precision for smooth movement and physics-like accumulation. Use fixed when you need to combine an int with fixed-point values or divide to get a fraction — for example fixed(1) / fixed(4) is 0.25. Convert back to a whole number for drawing with flr.

Parameters:

  • n — the integer to lift into fixed-point
program SmoothAccumulate {
  handler ComputeStep phase Start {
    let full_speed = fixed(3)
    let half_speed = full_speed / fixed(2)
    let two_steps = half_speed + half_speed
    print(floor(two_steps))
  }
}