Home / Docs / Specification / 29. Numerics
29.5 Equality and order
Release v0.4.0
==is identity.x == yexactly whenx.to_bits() == y.to_bits(). Sonan() == nan()istrue, and-0.0 == 0.0isfalse.!=is its negation.<is IEEE totalOrder:-infinity()< negative finite values <-0.0<0.0< positive finite values <infinity()<nan().x <= yisx < y or x == y.- IEEE comparison is the methods of §3 rule 3,
x.ieee_lt(other: y)and the others. - Consequences.
==is reflexive, symmetric and transitive, onF64and on every value that holds one;<is a strict total order, sosortis deterministic,-0.0sorts before0.0and NaN last;Map[F64, V]holds-0.0and0.0as two keys and NaN as one key. - Comparing with a literal zero is an error. Every comparison of an
F64with an operand that is a float literal of value zero, with or without unary-(0.0,-0.0,0.000), on either side, is U2033:==,!=,<,<=,>and>=,is, and awhenarm. The repairs:x.is_zero(),x.is_positive_zero()orx.is_negative_zero()for an equality;x.ieee_lt(other: 0.0)and the other IEEE methods, thenx.is_sign_negative(), for an ordering. No other comparison changes. - Other literal patterns. A
whenarm whose pattern is any other float literal or a range, andiswith such a literal, are U2032, with a repair to anifthat compares by==or by an IEEE method.fordoes not iterate overF64.