MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / compare

Method compare

vm/JavaAPI/src/java/lang/Float.java:267–282  ·  view source on GitHub ↗
(float f1, float f2)

Source from the content-addressed store, hash-verified

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);

Callers 5

equalsMethod · 0.95
setFilterBlurRadiusMethod · 0.95
compareToMethod · 0.95
equalsMethod · 0.95

Calls 2

isNaNMethod · 0.95
floatToIntBitsMethod · 0.95

Tested by 1

equalsMethod · 0.76