Skip to content

Commit

Permalink
comment on why float.compare is necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
douira committed Dec 28, 2023
1 parent f7c84b0 commit d411598
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public static long toMib(long bytes) {
* floating point values by their int bits (for example packed in a long).
*/
public static int floatToComparableInt(float f) {
// uses Float.compare to avoid issues comparing -0.0f and 0.0f
return Float.floatToRawIntBits(f) ^ (Float.compare(f, 0f) > 0 ? 0x80000000 : 0xffffffff);
}
}

0 comments on commit d411598

Please sign in to comment.