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>
This commit is contained in:
parent
effb3f637f
commit
2e0047514b
19 changed files with 80 additions and 80 deletions
29
docs/language/builtins/fn-floor.md
Normal file
29
docs/language/builtins/fn-floor.md
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
---
|
||||
id: fn-floor
|
||||
name: floor
|
||||
category: builtins
|
||||
kind: builtin
|
||||
tokens: floor
|
||||
sig: floor(x) -> int
|
||||
tip: Floor a fixed-point value down to the nearest integer.
|
||||
order: 50
|
||||
---
|
||||
|
||||
Converts a <code>fixed</code> (Q16.16) value back to an <code>int</code> by discarding the fractional part, rounding toward negative infinity. It is the counterpart to <code>fx</code>: you accumulate motion in fixed-point for sub-pixel smoothness, then <code>floor</code> the result to get the whole-pixel column or row to draw at. Because it floors rather than rounds, <code>floor(fixed(3) / fixed(2))</code> is <code>1</code>, not <code>2</code>. Use it wherever a fixed value must become an integer coordinate, count, or index.
|
||||
|
||||
Parameters:
|
||||
- `x` — the fixed-point value to floor
|
||||
|
||||
```ludic
|
||||
program FixedToPixels {
|
||||
const TILE_SIZE: int = 16
|
||||
|
||||
handler DrawWorld phase Render {
|
||||
Screen.clear(Color.MidnightBlue)
|
||||
let smooth_column = fixed(5) + fixed(1) / fixed(2)
|
||||
let pixel_x = floor(smooth_column) * TILE_SIZE
|
||||
Screen.fill_rectangle(x: pixel_x, y: 32, width: TILE_SIZE, height: TILE_SIZE, color: Color.LimeGreen)
|
||||
Screen.show()
|
||||
}
|
||||
}
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue