✓
Passing This code compiles and runs correctly.
Code
// Cross-target math builtins: the host-builtin family that lowers to
// `Math.*` in the JS emitter must produce identical numbers on both lanes —
// Zig builtins on one side, Math.* on the other, same source, same decimals.
import std/io
std/io:print("sin {{ @sin(0.5):d:.4 }} cos {{ @cos(0.5):d:.4 }} tan {{ @tan(0.5):d:.4 }}\n")
std/io:print("exp {{ @exp(1.0):d:.4 }} exp2 {{ @exp2(3.0):d:.4 }} log {{ @log(10.0):d:.4 }} log2 {{ @log2(8.0):d:.4 }} log10 {{ @log10(1000.0):d:.4 }}\n")
std/io:print("floor {{ @floor(1.7):d:.4 }} ceil {{ @ceil(1.2):d:.4 }} trunc {{ @trunc(-1.7):d:.4 }} sqrt {{ @sqrt(2.0):d:.4 }} abs {{ @abs(-3.5):d:.4 }}\n")
std/io:print("min {{ @min(1.0, 2.5):d:.4 }} max {{ @max(1.0, 2.5):d:.4 }}\n")
Actual
sin 0.4794 cos 0.8776 tan 0.5463
exp 2.7183 exp2 8.0000 log 2.3026 log2 3.0000 log10 3.0000
floor 1.0000 ceil 2.0000 trunc -1.0000 sqrt 1.4142 abs 3.5000
min 1.0000 max 2.5000
Expected output
✓ Zig✓ JavaScriptsin 0.4794 cos 0.8776 tan 0.5463
exp 2.7183 exp2 8.0000 log 2.3026 log2 3.0000 log10 3.0000
floor 1.0000 ceil 2.0000 trunc -1.0000 sqrt 1.4142 abs 3.5000
min 1.0000 max 2.5000
Flows
flow ~print click a branch to expand · @labels scroll to their anchor
print (expr: "sin {{ @sin(0.5):d:.4 }} cos {{ @cos(0.5):d:.4 }} tan {{ @tan(0.5):d:.4 }}\n")
flow ~print click a branch to expand · @labels scroll to their anchor
print (expr: "exp {{ @exp(1.0):d:.4 }} exp2 {{ @exp2(3.0):d:.4 }} log {{ @log(10.0):d:.4 }} log2 {{ @log2(8.0):d:.4 }} log10 {{ @log10(1000.0):d:.4 }}\n")
flow ~print click a branch to expand · @labels scroll to their anchor
print (expr: "floor {{ @floor(1.7):d:.4 }} ceil {{ @ceil(1.2):d:.4 }} trunc {{ @trunc(-1.7):d:.4 }} sqrt {{ @sqrt(2.0):d:.4 }} abs {{ @abs(-3.5):d:.4 }}\n")
flow ~print click a branch to expand · @labels scroll to their anchor
print (expr: "min {{ @min(1.0, 2.5):d:.4 }} max {{ @max(1.0, 2.5):d:.4 }}\n")
Test Configuration
MUST_RUN LANGUAGES: zig js