On 12/11/2017 04:57 AM, Alex Bennée wrote: > + if (a.cls == float_class_zero || b.cls == float_class_zero) { > + if (a.cls == float_class_normal) { > + return a.sign ? float_relation_less : float_relation_greater; > + } else if (b.cls == float_class_normal) { > + return b.sign ? float_relation_greater : float_relation_less; > + } else if (a.cls == b.cls) { > + return float_relation_equal; > + } > + }
This misses out on infinity handling, which should be like normals. Perhaps better as if (a.cls == float_class_zero) { if (b.cls == float_class_zero) { return float_relation_equal; } return b.sign ? float_relation_greater : float_relation_less; } else if (b.cls == float_class_zero) { return a.sign ? float_relation_less : float_relation_greater; } > + /* The only infinity we need to explicitly worry about is > + * comparing two together, otherwise the max_exp/sign details are > + * enough to compare to normal numbers > + */ I don't think it's wise to rely on the contents of .exp for float_class_inf. Really, the only valid member for that type is sign. Better as if (a.cls == float_class_inf) { if (b.cls == float_class_inf) { if (a.sign == b.sign) { return float_relation_equal; } } return a.sign ? float_relation_less : float_relation_greater; } else if (b.cls == float_class_inf) { return b.sign ? float_relation_less : float_relation_greater; } r~