Java Float Number Equal floatEquals(float a, float b)

Here you can find the source of floatEquals(float a, float b)

Description

Implements the semantics of Float#equals(Object) for two primitive floats.

License

Open Source License

Parameter

Parameter Description
a single-precision value
b single-precision value

Return

true if equal, false if not

Declaration

public static boolean floatEquals(float a, float b) 

Method Source Code

//package com.java2s;
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

public class Main {
    /**/*from w w  w  .ja va2s  .co  m*/
     * Implements the semantics of {@link Float#equals(Object)} for two
     * primitive floats.
     *
     * @param a single-precision value
     * @param b single-precision value
     * @return true if equal, false if not
     */
    public static boolean floatEquals(float a, float b) {
        return Float.floatToIntBits(a) == Float.floatToIntBits(b);
    }
}

Related

  1. areFloatsEqual(Float one, Float two)
  2. equal(float val1, float val2)
  3. equals(float f1, float f2)
  4. floatEqual(float a, float b, float epsilon)
  5. floatEqual(float f1, float f2)
  6. floatEquals(float x, float y)