w6c: float-aware unary minus (fix -1.0 emitting +1.0 bit pattern)

This commit is contained in:
2026-05-11 17:52:29 +09:00
parent e50849d5ec
commit 579cc39f9b
3 changed files with 40 additions and 22 deletions

View File

@@ -107,15 +107,10 @@ fn emitendrow(buf: *u8, off: i32) i32 = {
export fn main() i32 = {
// Classic Mandelbrot window. The y range is squashed to W/H so
// the picture looks roughly proportional in a terminal cell.
//
// XXX ww's compiler currently emits positive bit patterns for
// negative f64 literals (the unary minus is dropped during
// codegen). As a workaround we build negatives via 0.0 - x.
let z: f64 = 0.0;
let xmin: f64 = z - 2.5;
let xmax: f64 = 1.0;
let ymin: f64 = z - 1.1;
let ymax: f64 = 1.1;
let xmin: f64 = -2.5;
let xmax: f64 = 1.0;
let ymin: f64 = -1.1;
let ymax: f64 = 1.1;
let dx: f64 = (xmax - xmin) / (W: f64);
let dy: f64 = (ymax - ymin) / (H: f64);