A real literal was used as a pattern.
fun f (x : real) : int =
case x of
1.2 => 3
(** ^^^ real literal used as a pattern *)
| _ => 4
Consider checking that the given real is within some epsilon value of the desired real.
val eps = 0.01
fun f (x : real) : int =
if Real.abs (x - 1.2) <= eps then
3
else
4
Usage of Real.==
to check for equality between reals is discouraged, due to limitations around representing floating-point (aka, real
) numbers on most architectures.