define bodies are pasted raw #55

Closed
opened 2026-10-08 18:43:13 +02:00 by alex-eg · 0 comments
Owner

(define K (/ (cast 255 float) (cast 60 float))) emits
#define K cast(255, float) / cast(60, float): not translated, and
not parenthesized. With (define D (/ -1.0 6.0)), (* x D) becomes
x * -1.0 / 6.0. That's (x * -1.0) / 6.0, which rounds differently
from multiplying by the folded constant. Bit-exact code needs literal
values or typed vars.


Found with sexc dfafe8b while building vs-map-viewer (from its Sex-field-notes.org).

`(define K (/ (cast 255 float) (cast 60 float)))` emits `#define K cast(255, float) / cast(60, float)`: not translated, and not parenthesized. With `(define D (/ -1.0 6.0))`, `(* x D)` becomes `x * -1.0 / 6.0`. That's `(x * -1.0) / 6.0`, which rounds differently from multiplying by the folded constant. Bit-exact code needs literal values or typed `var`s. --- Found with sexc `dfafe8b` while building vs-map-viewer (from its `Sex-field-notes.org`).
alex-eg added the bug label 2026-10-08 18:43:13 +02:00
Sign in to join this conversation.