Java Abs absNegativeZeros(float f)

Here you can find the source of absNegativeZeros(float f)

Description

If f is -0.0f, return 0.0f; otherwise, return f .

License

Open Source License

Parameter

Parameter Description
f a float

Return

a float equal to f and not -0.0f

Declaration

public static float absNegativeZeros(float f) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from w  ww  . ja  v a2  s  .  co m
     * If {@code f} is -0.0f, return 0.0f; otherwise, return {@code f}.
     *
     * <ul>
     *  <li>{@code f} may be any {@code float}.</li>
     *  <li>The result is not negative zero.</li>
     * </ul>
     *
     * @param f a {@code float}
     * @return a {@code float} equal to {@code f} and not -0.0f
     */
    public static float absNegativeZeros(float f) {
        return f == 0.0f ? 0.0f : f;
    }

    /**
     * If {@code d} is -0.0, return 0.0; otherwise, return {@code d}.
     *
     * <ul>
     *  <li>{@code d} may be any {@code double}.</li>
     *  <li>The result is not negative zero.</li>
     * </ul>
     *
     * @param d a {@code double}
     * @return a {@code double} equal to {@code d} and not -0.0
     */
    public static double absNegativeZeros(double d) {
        return d == 0.0 ? 0.0 : d;
    }
}

Related

  1. absDelta(float f1, float f2)
  2. absDiff(long x, long y)
  3. absHash(Object obj)
  4. absNeg(final int a)
  5. absNeg(long a)
  6. Absolute(int a)