Hacker News new | ask | show | jobs
by xigoi 493 days ago
> If we have some positive 32-bit integers A and B then if A < B, f32::from_bits(A) < f32::from_bits(B)

That is, if both are valid floats that represent a finite non-zero number.

1 comments

Correct.

Floats support both -0 and 0 they compare equal but their bit representations don't. Zero can be tricky.

Not a numbers (NaNs) always compare as false. Their bit representations won't.