Files
pplus-web/mojo/stress/exact-literals.mojo
T
2026-10-05 03:03:38 +00:00

14 lines
522 B
Mojo

# probe: literal-only arithmetic is exact; with a variable it runs in Float64
# status: the expected output is Programming+'s interpreter's prediction; corpus.py verify confirms or refutes it on godbolt
# expect-stdout: 0.3 0.3
# expect-stdout: 0.30000000000000004 0.30000000000000004
# expect-stdout: 2.0 1.0
# expect-stdout: 1.0
def main():
var one = 1.0
print(0.1 + 0.2, 0.1 * 3.0)
var tenth = 0.1
print(tenth + 0.2, tenth * 3.0)
print(2.0 / 3.0 * 3.0, one / 3.0 * 3.0)
print(1e16 + 1.0 - 1e16)