15 lines
788 B
Mojo
15 lines
788 B
Mojo
# probe: with contraction on (--fp-mode contract=fast, Mojo's default; the pin builds with it off), is x * x - x rounded the same when x is known at build time and when it arrives at run time? (no: from stdin the built program fuses it into one rounding, -0.22222222222222224; from a literal the compiler works it out while building, rounded twice, -0.2222222222222222; float-contract-runtime-off is the same program with contraction off)
|
|
# args: --fp-mode contract=fast
|
|
# stdin: 2 3\n
|
|
# expect-stdout: -0.22222222222222224
|
|
# expect-stdout: -0.2222222222222222
|
|
def square_less(x: Float64) -> Float64:
|
|
return x * x - x
|
|
|
|
|
|
def main() raises:
|
|
var w = input().split(" ")
|
|
var x = Float64(atol(w[0])) / Float64(atol(w[1]))
|
|
print(square_less(x))
|
|
print(square_less(2.0 / 3.0))
|