Newton's method for square root -- an algorithm that needs float arithmetic:
check_both_float(
\\fn sqrt(n: f64) f64 {
\\ var guess: f64 = n / 2.0;
\\ for (0..20) |i| {
\\ guess = (guess + n / guess) / 2.0;
\\ }
\\ return guess;
\\}
\\sqrt(2.0)
, 1.41421);
Twenty iterations of Newton's method, starting from n/2. Each iteration: guess = (guess + n/guess) / 2. Converges to sqrt(2) = 1.41421356... in about 5 iterations, but 20 is safe.
This is real numerical computation. The same algorithm, the same source code, running through both the interpreter (using @bitCast to pack/unpack floats) and the compiler (emitting f64.div, f64.add, f64.mul). Agreement proves both paths handle floating point correctly.