12 lines
470 B
Mojo
12 lines
470 B
Mojo
# probe: with contraction on (--fp-mode contract=fast, Mojo's default; the pin builds with it off), does the compiler fuse a * b - c into one rounding when the operands are literals? (fused, 0.1 * 10.0 - 1.0 is 5.551115123125783e-17; rounded twice it is 0.0)
|
|
# args: --fp-mode contract=fast
|
|
def fused(a: Float64, b: Float64, c: Float64) -> Float64:
|
|
return a * b - c
|
|
|
|
|
|
def main():
|
|
var a = 0.1
|
|
var b = 10.0
|
|
var c = 1.0
|
|
print(a * b - c, fused(a, b, c))
|