| 265 | private static final int NEGATIVE_ZERO_BITS=floatToIntBits(-0f); |
| 266 | |
| 267 | public static int compare(float f1, float f2) { |
| 268 | if (isNaN(f1) && isNaN(f2)) { |
| 269 | return 0; |
| 270 | } else if (isNaN(f1)) { |
| 271 | return 1; |
| 272 | } else if (isNaN(f2)) { |
| 273 | return -1; |
| 274 | } else if (f1 == 0f && f2 == 0f) { |
| 275 | int f1bits = floatToIntBits(f1); |
| 276 | int f2bits = floatToIntBits(f2); |
| 277 | return f1bits == f2bits ? 0 : |
| 278 | f1bits == NEGATIVE_ZERO_BITS ? -1 : 1; |
| 279 | } else { |
| 280 | return f1 < f2 ? -1 : f1 > f2 ? 1 : 0; |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | public int compareTo(Float another) { |
| 285 | return compare(value, another.value); |