diff options
| author | 2026-02-14 14:00:23 -0600 | |
|---|---|---|
| committer | 2026-02-14 14:00:23 -0600 | |
| commit | 22dc47cbcd3eec7d8c393c7586dcbef8898a6765 (patch) | |
| tree | af0423bfd1b9b01b0ef770fd624546ab0b8fb9f5 | |
| parent | Don't use built-in rounding. (diff) | |
Make order of operations consistent.cjanet-jit
| -rw-r--r-- | spork/gfx2d-codegen.janet | 2 | ||||
| -rw-r--r-- | test/suite-gfx2d.janet | 14 |
2 files changed, 10 insertions, 6 deletions
diff --git a/spork/gfx2d-codegen.janet b/spork/gfx2d-codegen.janet index 2f478da..0da08d7 100644 --- a/spork/gfx2d-codegen.janet +++ b/spork/gfx2d-codegen.janet @@ -525,7 +525,7 @@ (function colorjoin :static :inline [r:int g:int b:int a:int] -> uint32_t - (return (+ r (<< g 8) (<< b 16) (<< a 24)))) + (return (+ (cast uint32_t r) (<< (cast uint32_t g) 8) (<< (cast uint32_t b) 16) (<< (cast uint32_t a) 24)))) (def- colors {:red 0xFF0000FF diff --git a/test/suite-gfx2d.janet b/test/suite-gfx2d.janet index c2042f4..35ef6fb 100644 --- a/test/suite-gfx2d.janet +++ b/test/suite-gfx2d.janet @@ -302,13 +302,17 @@ [] (def npoints 100) (def rng (math/rng 10)) + # Order of calculation must be deterministic between Janet versions! Do NOT inline this into the struct in `data`. + (def t1 (seq [i :range [0 npoints]] (+ (math/log (+ i 1)) (* 0.3 (math/rng-uniform rng))))) + (def t2 (seq [i :range [0 npoints]] (+ (* 0.94 (math/log (+ i 1))) (* 0.2 (math/rng-uniform rng))))) + (def t3 (seq [i :range [0 npoints]] (+ (* 0.79 (math/log (+ i 1))) (* 0.4 (math/rng-uniform rng))))) + (def t4 (seq [i :range [0 npoints]] (+ (* 0.45 (math/log (+ i 8))) (* 0.4 (math/rng-uniform rng))))) (def data {:timestamp (map |(/ $ 10) (range npoints)) - :temperature-1 (seq [i :range [0 npoints]] (+ (math/log (+ i 1)) (* 0.3 (math/rng-uniform rng)))) - :temperature-2 (seq [i :range [0 npoints]] (+ (* 0.94 (math/log (+ i 1))) (* 0.2 (math/rng-uniform rng)))) - :temperature-3 (seq [i :range [0 npoints]] (+ (* 0.79 (math/log (+ i 1))) (* 0.4 (math/rng-uniform rng)))) - :temperature-4 (seq [i :range [0 npoints]] (+ (* 0.45 (math/log (+ i 8))) (* 0.4 (math/rng-uniform rng)))) - }) + :temperature-1 t1 + :temperature-2 t2 + :temperature-3 t3 + :temperature-4 t4}) (def columns [:temperature-1 :temperature-2 :temperature-3 :temperature-4]) (def img (charts/line-chart |
