< prev index next >

src/java.base/share/classes/java/lang/Math.java

Print this page




1960         }
1961     }
1962 
1963     /**
1964      * Returns the signum function of the argument; zero if the argument
1965      * is zero, 1.0 if the argument is greater than zero, -1.0 if the
1966      * argument is less than zero.
1967      *
1968      * <p>Special Cases:
1969      * <ul>
1970      * <li> If the argument is NaN, then the result is NaN.
1971      * <li> If the argument is positive zero or negative zero, then the
1972      *      result is the same as the argument.
1973      * </ul>
1974      *
1975      * @param d the floating-point value whose signum is to be returned
1976      * @return the signum function of the argument
1977      * @author Joseph D. Darcy
1978      * @since 1.5
1979      */

1980     public static double signum(double d) {
1981         return (d == 0.0 || Double.isNaN(d))?d:copySign(1.0, d);
1982     }
1983 
1984     /**
1985      * Returns the signum function of the argument; zero if the argument
1986      * is zero, 1.0f if the argument is greater than zero, -1.0f if the
1987      * argument is less than zero.
1988      *
1989      * <p>Special Cases:
1990      * <ul>
1991      * <li> If the argument is NaN, then the result is NaN.
1992      * <li> If the argument is positive zero or negative zero, then the
1993      *      result is the same as the argument.
1994      * </ul>
1995      *
1996      * @param f the floating-point value whose signum is to be returned
1997      * @return the signum function of the argument
1998      * @author Joseph D. Darcy
1999      * @since 1.5
2000      */

2001     public static float signum(float f) {
2002         return (f == 0.0f || Float.isNaN(f))?f:copySign(1.0f, f);
2003     }
2004 
2005     /**
2006      * Returns the hyperbolic sine of a {@code double} value.
2007      * The hyperbolic sine of <i>x</i> is defined to be
2008      * (<i>e<sup>x</sup>&nbsp;-&nbsp;e<sup>-x</sup></i>)/2
2009      * where <i>e</i> is {@linkplain Math#E Euler's number}.
2010      *
2011      * <p>Special cases:
2012      * <ul>
2013      *
2014      * <li>If the argument is NaN, then the result is NaN.
2015      *
2016      * <li>If the argument is infinite, then the result is an infinity
2017      * with the same sign as the argument.
2018      *
2019      * <li>If the argument is zero, then the result is a zero with the
2020      * same sign as the argument.




1960         }
1961     }
1962 
1963     /**
1964      * Returns the signum function of the argument; zero if the argument
1965      * is zero, 1.0 if the argument is greater than zero, -1.0 if the
1966      * argument is less than zero.
1967      *
1968      * <p>Special Cases:
1969      * <ul>
1970      * <li> If the argument is NaN, then the result is NaN.
1971      * <li> If the argument is positive zero or negative zero, then the
1972      *      result is the same as the argument.
1973      * </ul>
1974      *
1975      * @param d the floating-point value whose signum is to be returned
1976      * @return the signum function of the argument
1977      * @author Joseph D. Darcy
1978      * @since 1.5
1979      */
1980     @HotSpotIntrinsicCandidate
1981     public static double signum(double d) {
1982         return (d == 0.0 || Double.isNaN(d))?d:copySign(1.0, d);
1983     }
1984 
1985     /**
1986      * Returns the signum function of the argument; zero if the argument
1987      * is zero, 1.0f if the argument is greater than zero, -1.0f if the
1988      * argument is less than zero.
1989      *
1990      * <p>Special Cases:
1991      * <ul>
1992      * <li> If the argument is NaN, then the result is NaN.
1993      * <li> If the argument is positive zero or negative zero, then the
1994      *      result is the same as the argument.
1995      * </ul>
1996      *
1997      * @param f the floating-point value whose signum is to be returned
1998      * @return the signum function of the argument
1999      * @author Joseph D. Darcy
2000      * @since 1.5
2001      */
2002     @HotSpotIntrinsicCandidate
2003     public static float signum(float f) {
2004         return (f == 0.0f || Float.isNaN(f))?f:copySign(1.0f, f);
2005     }
2006 
2007     /**
2008      * Returns the hyperbolic sine of a {@code double} value.
2009      * The hyperbolic sine of <i>x</i> is defined to be
2010      * (<i>e<sup>x</sup>&nbsp;-&nbsp;e<sup>-x</sup></i>)/2
2011      * where <i>e</i> is {@linkplain Math#E Euler's number}.
2012      *
2013      * <p>Special cases:
2014      * <ul>
2015      *
2016      * <li>If the argument is NaN, then the result is NaN.
2017      *
2018      * <li>If the argument is infinite, then the result is an infinity
2019      * with the same sign as the argument.
2020      *
2021      * <li>If the argument is zero, then the result is a zero with the
2022      * same sign as the argument.


< prev index next >