Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/misc/FpUtils.java
38829 views
/*1* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.misc;2627import sun.misc.FloatConsts;28import sun.misc.DoubleConsts;2930/**31* The class {@code FpUtils} contains static utility methods for32* manipulating and inspecting {@code float} and33* {@code double} floating-point numbers. These methods include34* functionality recommended or required by the IEEE 75435* floating-point standard.36*37* @author Joseph D. Darcy38*/3940public class FpUtils {41/*42* The methods in this class are reasonably implemented using43* direct or indirect bit-level manipulation of floating-point44* values. However, having access to the IEEE 754 recommended45* functions would obviate the need for most programmers to engage46* in floating-point bit-twiddling.47*48* An IEEE 754 number has three fields, from most significant bit49* to to least significant, sign, exponent, and significand.50*51* msb lsb52* [sign|exponent| fractional_significand]53*54* Using some encoding cleverness, explained below, the high order55* bit of the logical significand does not need to be explicitly56* stored, thus "fractional_significand" instead of simply57* "significand" in the figure above.58*59* For finite normal numbers, the numerical value encoded is60*61* (-1)^sign * 2^(exponent)*(1.fractional_significand)62*63* Most finite floating-point numbers are normalized; the exponent64* value is reduced until the leading significand bit is 1.65* Therefore, the leading 1 is redundant and is not explicitly66* stored. If a numerical value is so small it cannot be67* normalized, it has a subnormal representation. Subnormal68* numbers don't have a leading 1 in their significand; subnormals69* are encoding using a special exponent value. In other words,70* the high-order bit of the logical significand can be elided in71* from the representation in either case since the bit's value is72* implicit from the exponent value.73*74* The exponent field uses a biased representation; if the bits of75* the exponent are interpreted as a unsigned integer E, the76* exponent represented is E - E_bias where E_bias depends on the77* floating-point format. E can range between E_min and E_max,78* constants which depend on the floating-point format. E_min and79* E_max are -126 and +127 for float, -1022 and +1023 for double.80*81* The 32-bit float format has 1 sign bit, 8 exponent bits, and 2382* bits for the significand (which is logically 24 bits wide83* because of the implicit bit). The 64-bit double format has 184* sign bit, 11 exponent bits, and 52 bits for the significand85* (logically 53 bits).86*87* Subnormal numbers and zero have the special exponent value88* E_min -1; the numerical value represented by a subnormal is:89*90* (-1)^sign * 2^(E_min)*(0.fractional_significand)91*92* Zero is represented by all zero bits in the exponent and all93* zero bits in the significand; zero can have either sign.94*95* Infinity and NaN are encoded using the exponent value E_max +96* 1. Signed infinities have all significand bits zero; NaNs have97* at least one non-zero significand bit.98*99* The details of IEEE 754 floating-point encoding will be used in100* the methods below without further comment. For further101* exposition on IEEE 754 numbers, see "IEEE Standard for Binary102* Floating-Point Arithmetic" ANSI/IEEE Std 754-1985 or William103* Kahan's "Lecture Notes on the Status of IEEE Standard 754 for104* Binary Floating-Point Arithmetic",105* http://www.cs.berkeley.edu/~wkahan/ieee754status/ieee754.ps.106*107* Many of this class's methods are members of the set of IEEE 754108* recommended functions or similar functions recommended or109* required by IEEE 754R. Discussion of various implementation110* techniques for these functions have occurred in:111*112* W.J. Cody and Jerome T. Coonen, "Algorithm 772 Functions to113* Support the IEEE Standard for Binary Floating-Point114* Arithmetic," ACM Transactions on Mathematical Software,115* vol. 19, no. 4, December 1993, pp. 443-451.116*117* Joseph D. Darcy, "Writing robust IEEE recommended functions in118* ``100% Pure Java''(TM)," University of California, Berkeley119* technical report UCB//CSD-98-1009.120*/121122/**123* Don't let anyone instantiate this class.124*/125private FpUtils() {}126127// Helper Methods128129// The following helper methods are used in the implementation of130// the public recommended functions; they generally omit certain131// tests for exception cases.132133/**134* Returns unbiased exponent of a {@code double}.135* @deprecated Use Math.getExponent.136*/137@Deprecated138public static int getExponent(double d){139return Math.getExponent(d);140}141142/**143* Returns unbiased exponent of a {@code float}.144* @deprecated Use Math.getExponent.145*/146@Deprecated147public static int getExponent(float f){148return Math.getExponent(f);149}150151152/**153* Returns the first floating-point argument with the sign of the154* second floating-point argument. Note that unlike the {@link155* FpUtils#copySign(double, double) copySign} method, this method156* does not require NaN {@code sign} arguments to be treated157* as positive values; implementations are permitted to treat some158* NaN arguments as positive and other NaN arguments as negative159* to allow greater performance.160*161* @param magnitude the parameter providing the magnitude of the result162* @param sign the parameter providing the sign of the result163* @return a value with the magnitude of {@code magnitude}164* and the sign of {@code sign}.165* @author Joseph D. Darcy166* @deprecated Use Math.copySign.167*/168@Deprecated169public static double rawCopySign(double magnitude, double sign) {170return Math.copySign(magnitude, sign);171}172173/**174* Returns the first floating-point argument with the sign of the175* second floating-point argument. Note that unlike the {@link176* FpUtils#copySign(float, float) copySign} method, this method177* does not require NaN {@code sign} arguments to be treated178* as positive values; implementations are permitted to treat some179* NaN arguments as positive and other NaN arguments as negative180* to allow greater performance.181*182* @param magnitude the parameter providing the magnitude of the result183* @param sign the parameter providing the sign of the result184* @return a value with the magnitude of {@code magnitude}185* and the sign of {@code sign}.186* @author Joseph D. Darcy187* @deprecated Use Math.copySign.188*/189@Deprecated190public static float rawCopySign(float magnitude, float sign) {191return Math.copySign(magnitude, sign);192}193194/* ***************************************************************** */195196/**197* Returns {@code true} if the argument is a finite198* floating-point value; returns {@code false} otherwise (for199* NaN and infinity arguments).200*201* @param d the {@code double} value to be tested202* @return {@code true} if the argument is a finite203* floating-point value, {@code false} otherwise.204* @deprecated Use Double.isFinite.205*/206@Deprecated207public static boolean isFinite(double d) {208return Double.isFinite(d);209}210211/**212* Returns {@code true} if the argument is a finite213* floating-point value; returns {@code false} otherwise (for214* NaN and infinity arguments).215*216* @param f the {@code float} value to be tested217* @return {@code true} if the argument is a finite218* floating-point value, {@code false} otherwise.219* @deprecated Use Float.isFinite.220*/221@Deprecated222public static boolean isFinite(float f) {223return Float.isFinite(f);224}225226/**227* Returns {@code true} if the specified number is infinitely228* large in magnitude, {@code false} otherwise.229*230* <p>Note that this method is equivalent to the {@link231* Double#isInfinite(double) Double.isInfinite} method; the232* functionality is included in this class for convenience.233*234* @param d the value to be tested.235* @return {@code true} if the value of the argument is positive236* infinity or negative infinity; {@code false} otherwise.237*/238public static boolean isInfinite(double d) {239return Double.isInfinite(d);240}241242/**243* Returns {@code true} if the specified number is infinitely244* large in magnitude, {@code false} otherwise.245*246* <p>Note that this method is equivalent to the {@link247* Float#isInfinite(float) Float.isInfinite} method; the248* functionality is included in this class for convenience.249*250* @param f the value to be tested.251* @return {@code true} if the argument is positive infinity or252* negative infinity; {@code false} otherwise.253*/254public static boolean isInfinite(float f) {255return Float.isInfinite(f);256}257258/**259* Returns {@code true} if the specified number is a260* Not-a-Number (NaN) value, {@code false} otherwise.261*262* <p>Note that this method is equivalent to the {@link263* Double#isNaN(double) Double.isNaN} method; the functionality is264* included in this class for convenience.265*266* @param d the value to be tested.267* @return {@code true} if the value of the argument is NaN;268* {@code false} otherwise.269*/270public static boolean isNaN(double d) {271return Double.isNaN(d);272}273274/**275* Returns {@code true} if the specified number is a276* Not-a-Number (NaN) value, {@code false} otherwise.277*278* <p>Note that this method is equivalent to the {@link279* Float#isNaN(float) Float.isNaN} method; the functionality is280* included in this class for convenience.281*282* @param f the value to be tested.283* @return {@code true} if the argument is NaN;284* {@code false} otherwise.285*/286public static boolean isNaN(float f) {287return Float.isNaN(f);288}289290/**291* Returns {@code true} if the unordered relation holds292* between the two arguments. When two floating-point values are293* unordered, one value is neither less than, equal to, nor294* greater than the other. For the unordered relation to be true,295* at least one argument must be a {@code NaN}.296*297* @param arg1 the first argument298* @param arg2 the second argument299* @return {@code true} if at least one argument is a NaN,300* {@code false} otherwise.301*/302public static boolean isUnordered(double arg1, double arg2) {303return isNaN(arg1) || isNaN(arg2);304}305306/**307* Returns {@code true} if the unordered relation holds308* between the two arguments. When two floating-point values are309* unordered, one value is neither less than, equal to, nor310* greater than the other. For the unordered relation to be true,311* at least one argument must be a {@code NaN}.312*313* @param arg1 the first argument314* @param arg2 the second argument315* @return {@code true} if at least one argument is a NaN,316* {@code false} otherwise.317*/318public static boolean isUnordered(float arg1, float arg2) {319return isNaN(arg1) || isNaN(arg2);320}321322/**323* Returns unbiased exponent of a {@code double}; for324* subnormal values, the number is treated as if it were325* normalized. That is for all finite, non-zero, positive numbers326* <i>x</i>, <code>scalb(<i>x</i>, -ilogb(<i>x</i>))</code> is327* always in the range [1, 2).328* <p>329* Special cases:330* <ul>331* <li> If the argument is NaN, then the result is 2<sup>30</sup>.332* <li> If the argument is infinite, then the result is 2<sup>28</sup>.333* <li> If the argument is zero, then the result is -(2<sup>28</sup>).334* </ul>335*336* @param d floating-point number whose exponent is to be extracted337* @return unbiased exponent of the argument.338* @author Joseph D. Darcy339*/340public static int ilogb(double d) {341int exponent = getExponent(d);342343switch (exponent) {344case DoubleConsts.MAX_EXPONENT+1: // NaN or infinity345if( isNaN(d) )346return (1<<30); // 2^30347else // infinite value348return (1<<28); // 2^28349350case DoubleConsts.MIN_EXPONENT-1: // zero or subnormal351if(d == 0.0) {352return -(1<<28); // -(2^28)353}354else {355long transducer = Double.doubleToRawLongBits(d);356357/*358* To avoid causing slow arithmetic on subnormals,359* the scaling to determine when d's significand360* is normalized is done in integer arithmetic.361* (there must be at least one "1" bit in the362* significand since zero has been screened out.363*/364365// isolate significand bits366transducer &= DoubleConsts.SIGNIF_BIT_MASK;367assert(transducer != 0L);368369// This loop is simple and functional. We might be370// able to do something more clever that was faster;371// e.g. number of leading zero detection on372// (transducer << (# exponent and sign bits).373while (transducer <374(1L << (DoubleConsts.SIGNIFICAND_WIDTH - 1))) {375transducer *= 2;376exponent--;377}378exponent++;379assert( exponent >=380DoubleConsts.MIN_EXPONENT - (DoubleConsts.SIGNIFICAND_WIDTH-1) &&381exponent < DoubleConsts.MIN_EXPONENT);382return exponent;383}384385default:386assert( exponent >= DoubleConsts.MIN_EXPONENT &&387exponent <= DoubleConsts.MAX_EXPONENT);388return exponent;389}390}391392/**393* Returns unbiased exponent of a {@code float}; for394* subnormal values, the number is treated as if it were395* normalized. That is for all finite, non-zero, positive numbers396* <i>x</i>, <code>scalb(<i>x</i>, -ilogb(<i>x</i>))</code> is397* always in the range [1, 2).398* <p>399* Special cases:400* <ul>401* <li> If the argument is NaN, then the result is 2<sup>30</sup>.402* <li> If the argument is infinite, then the result is 2<sup>28</sup>.403* <li> If the argument is zero, then the result is -(2<sup>28</sup>).404* </ul>405*406* @param f floating-point number whose exponent is to be extracted407* @return unbiased exponent of the argument.408* @author Joseph D. Darcy409*/410public static int ilogb(float f) {411int exponent = getExponent(f);412413switch (exponent) {414case FloatConsts.MAX_EXPONENT+1: // NaN or infinity415if( isNaN(f) )416return (1<<30); // 2^30417else // infinite value418return (1<<28); // 2^28419420case FloatConsts.MIN_EXPONENT-1: // zero or subnormal421if(f == 0.0f) {422return -(1<<28); // -(2^28)423}424else {425int transducer = Float.floatToRawIntBits(f);426427/*428* To avoid causing slow arithmetic on subnormals,429* the scaling to determine when f's significand430* is normalized is done in integer arithmetic.431* (there must be at least one "1" bit in the432* significand since zero has been screened out.433*/434435// isolate significand bits436transducer &= FloatConsts.SIGNIF_BIT_MASK;437assert(transducer != 0);438439// This loop is simple and functional. We might be440// able to do something more clever that was faster;441// e.g. number of leading zero detection on442// (transducer << (# exponent and sign bits).443while (transducer <444(1 << (FloatConsts.SIGNIFICAND_WIDTH - 1))) {445transducer *= 2;446exponent--;447}448exponent++;449assert( exponent >=450FloatConsts.MIN_EXPONENT - (FloatConsts.SIGNIFICAND_WIDTH-1) &&451exponent < FloatConsts.MIN_EXPONENT);452return exponent;453}454455default:456assert( exponent >= FloatConsts.MIN_EXPONENT &&457exponent <= FloatConsts.MAX_EXPONENT);458return exponent;459}460}461462463/*464* The scalb operation should be reasonably fast; however, there465* are tradeoffs in writing a method to minimize the worst case466* performance and writing a method to minimize the time for467* expected common inputs. Some processors operate very slowly on468* subnormal operands, taking hundreds or thousands of cycles for469* one floating-point add or multiply as opposed to, say, four470* cycles for normal operands. For processors with very slow471* subnormal execution, scalb would be fastest if written entirely472* with integer operations; in other words, scalb would need to473* include the logic of performing correct rounding of subnormal474* values. This could be reasonably done in at most a few hundred475* cycles. However, this approach may penalize normal operations476* since at least the exponent of the floating-point argument must477* be examined.478*479* The approach taken in this implementation is a compromise.480* Floating-point multiplication is used to do most of the work;481* but knowingly multiplying by a subnormal scaling factor is482* avoided. However, the floating-point argument is not examined483* to see whether or not it is subnormal since subnormal inputs484* are assumed to be rare. At most three multiplies are needed to485* scale from the largest to smallest exponent ranges (scaling486* down, at most two multiplies are needed if subnormal scaling487* factors are allowed). However, in this implementation an488* expensive integer remainder operation is avoided at the cost of489* requiring five floating-point multiplies in the worst case,490* which should still be a performance win.491*492* If scaling of entire arrays is a concern, it would probably be493* more efficient to provide a double[] scalb(double[], int)494* version of scalb to avoid having to recompute the needed495* scaling factors for each floating-point value.496*/497498/**499* Return {@code d} ×500* 2<sup>{@code scale_factor}</sup> rounded as if performed501* by a single correctly rounded floating-point multiply to a502* member of the double value set. See section 4.2.3 of503* <cite>The Java™ Language Specification</cite>504* for a discussion of floating-point505* value sets. If the exponent of the result is between the506* {@code double}'s minimum exponent and maximum exponent,507* the answer is calculated exactly. If the exponent of the508* result would be larger than {@code doubles}'s maximum509* exponent, an infinity is returned. Note that if the result is510* subnormal, precision may be lost; that is, when {@code scalb(x,511* n)} is subnormal, {@code scalb(scalb(x, n), -n)} may512* not equal <i>x</i>. When the result is non-NaN, the result has513* the same sign as {@code d}.514*515*<p>516* Special cases:517* <ul>518* <li> If the first argument is NaN, NaN is returned.519* <li> If the first argument is infinite, then an infinity of the520* same sign is returned.521* <li> If the first argument is zero, then a zero of the same522* sign is returned.523* </ul>524*525* @param d number to be scaled by a power of two.526* @param scale_factor power of 2 used to scale {@code d}527* @return {@code d * }2<sup>{@code scale_factor}</sup>528* @author Joseph D. Darcy529* @deprecated Use Math.scalb.530*/531@Deprecated532public static double scalb(double d, int scale_factor) {533return Math.scalb(d, scale_factor);534}535536/**537* Return {@code f} ×538* 2<sup>{@code scale_factor}</sup> rounded as if performed539* by a single correctly rounded floating-point multiply to a540* member of the float value set. See section 4.2.3 of541* <cite>The Java™ Language Specification</cite>542* for a discussion of floating-point543* value sets. If the exponent of the result is between the544* {@code float}'s minimum exponent and maximum exponent, the545* answer is calculated exactly. If the exponent of the result546* would be larger than {@code float}'s maximum exponent, an547* infinity is returned. Note that if the result is subnormal,548* precision may be lost; that is, when {@code scalb(x, n)}549* is subnormal, {@code scalb(scalb(x, n), -n)} may not equal550* <i>x</i>. When the result is non-NaN, the result has the same551* sign as {@code f}.552*553*<p>554* Special cases:555* <ul>556* <li> If the first argument is NaN, NaN is returned.557* <li> If the first argument is infinite, then an infinity of the558* same sign is returned.559* <li> If the first argument is zero, then a zero of the same560* sign is returned.561* </ul>562*563* @param f number to be scaled by a power of two.564* @param scale_factor power of 2 used to scale {@code f}565* @return {@code f * }2<sup>{@code scale_factor}</sup>566* @author Joseph D. Darcy567* @deprecated Use Math.scalb.568*/569@Deprecated570public static float scalb(float f, int scale_factor) {571return Math.scalb(f, scale_factor);572}573574/**575* Returns the floating-point number adjacent to the first576* argument in the direction of the second argument. If both577* arguments compare as equal the second argument is returned.578*579* <p>580* Special cases:581* <ul>582* <li> If either argument is a NaN, then NaN is returned.583*584* <li> If both arguments are signed zeros, {@code direction}585* is returned unchanged (as implied by the requirement of586* returning the second argument if the arguments compare as587* equal).588*589* <li> If {@code start} is590* ±{@code Double.MIN_VALUE} and {@code direction}591* has a value such that the result should have a smaller592* magnitude, then a zero with the same sign as {@code start}593* is returned.594*595* <li> If {@code start} is infinite and596* {@code direction} has a value such that the result should597* have a smaller magnitude, {@code Double.MAX_VALUE} with the598* same sign as {@code start} is returned.599*600* <li> If {@code start} is equal to ±601* {@code Double.MAX_VALUE} and {@code direction} has a602* value such that the result should have a larger magnitude, an603* infinity with same sign as {@code start} is returned.604* </ul>605*606* @param start starting floating-point value607* @param direction value indicating which of608* {@code start}'s neighbors or {@code start} should609* be returned610* @return The floating-point number adjacent to {@code start} in the611* direction of {@code direction}.612* @author Joseph D. Darcy613* @deprecated Use Math.nextAfter614*/615@Deprecated616public static double nextAfter(double start, double direction) {617return Math.nextAfter(start, direction);618}619620/**621* Returns the floating-point number adjacent to the first622* argument in the direction of the second argument. If both623* arguments compare as equal, the second argument is returned.624*625* <p>626* Special cases:627* <ul>628* <li> If either argument is a NaN, then NaN is returned.629*630* <li> If both arguments are signed zeros, a {@code float}631* zero with the same sign as {@code direction} is returned632* (as implied by the requirement of returning the second argument633* if the arguments compare as equal).634*635* <li> If {@code start} is636* ±{@code Float.MIN_VALUE} and {@code direction}637* has a value such that the result should have a smaller638* magnitude, then a zero with the same sign as {@code start}639* is returned.640*641* <li> If {@code start} is infinite and642* {@code direction} has a value such that the result should643* have a smaller magnitude, {@code Float.MAX_VALUE} with the644* same sign as {@code start} is returned.645*646* <li> If {@code start} is equal to ±647* {@code Float.MAX_VALUE} and {@code direction} has a648* value such that the result should have a larger magnitude, an649* infinity with same sign as {@code start} is returned.650* </ul>651*652* @param start starting floating-point value653* @param direction value indicating which of654* {@code start}'s neighbors or {@code start} should655* be returned656* @return The floating-point number adjacent to {@code start} in the657* direction of {@code direction}.658* @author Joseph D. Darcy659* @deprecated Use Math.nextAfter.660*/661@Deprecated662public static float nextAfter(float start, double direction) {663return Math.nextAfter(start, direction);664}665666/**667* Returns the floating-point value adjacent to {@code d} in668* the direction of positive infinity. This method is669* semantically equivalent to {@code nextAfter(d,670* Double.POSITIVE_INFINITY)}; however, a {@code nextUp}671* implementation may run faster than its equivalent672* {@code nextAfter} call.673*674* <p>Special Cases:675* <ul>676* <li> If the argument is NaN, the result is NaN.677*678* <li> If the argument is positive infinity, the result is679* positive infinity.680*681* <li> If the argument is zero, the result is682* {@code Double.MIN_VALUE}683*684* </ul>685*686* @param d starting floating-point value687* @return The adjacent floating-point value closer to positive688* infinity.689* @author Joseph D. Darcy690* @deprecated use Math.nextUp.691*/692@Deprecated693public static double nextUp(double d) {694return Math.nextUp(d);695}696697/**698* Returns the floating-point value adjacent to {@code f} in699* the direction of positive infinity. This method is700* semantically equivalent to {@code nextAfter(f,701* Double.POSITIVE_INFINITY)}; however, a {@code nextUp}702* implementation may run faster than its equivalent703* {@code nextAfter} call.704*705* <p>Special Cases:706* <ul>707* <li> If the argument is NaN, the result is NaN.708*709* <li> If the argument is positive infinity, the result is710* positive infinity.711*712* <li> If the argument is zero, the result is713* {@code Float.MIN_VALUE}714*715* </ul>716*717* @param f starting floating-point value718* @return The adjacent floating-point value closer to positive719* infinity.720* @author Joseph D. Darcy721* @deprecated Use Math.nextUp.722*/723@Deprecated724public static float nextUp(float f) {725return Math.nextUp(f);726}727728/**729* Returns the floating-point value adjacent to {@code d} in730* the direction of negative infinity. This method is731* semantically equivalent to {@code nextAfter(d,732* Double.NEGATIVE_INFINITY)}; however, a733* {@code nextDown} implementation may run faster than its734* equivalent {@code nextAfter} call.735*736* <p>Special Cases:737* <ul>738* <li> If the argument is NaN, the result is NaN.739*740* <li> If the argument is negative infinity, the result is741* negative infinity.742*743* <li> If the argument is zero, the result is744* {@code -Double.MIN_VALUE}745*746* </ul>747*748* @param d starting floating-point value749* @return The adjacent floating-point value closer to negative750* infinity.751* @author Joseph D. Darcy752* @deprecated Use Math.nextDown.753*/754@Deprecated755public static double nextDown(double d) {756return Math.nextDown(d);757}758759/**760* Returns the floating-point value adjacent to {@code f} in761* the direction of negative infinity. This method is762* semantically equivalent to {@code nextAfter(f,763* Float.NEGATIVE_INFINITY)}; however, a764* {@code nextDown} implementation may run faster than its765* equivalent {@code nextAfter} call.766*767* <p>Special Cases:768* <ul>769* <li> If the argument is NaN, the result is NaN.770*771* <li> If the argument is negative infinity, the result is772* negative infinity.773*774* <li> If the argument is zero, the result is775* {@code -Float.MIN_VALUE}776*777* </ul>778*779* @param f starting floating-point value780* @return The adjacent floating-point value closer to negative781* infinity.782* @author Joseph D. Darcy783* @deprecated Use Math.nextDown.784*/785@Deprecated786public static double nextDown(float f) {787return Math.nextDown(f);788}789790/**791* Returns the first floating-point argument with the sign of the792* second floating-point argument. For this method, a NaN793* {@code sign} argument is always treated as if it were794* positive.795*796* @param magnitude the parameter providing the magnitude of the result797* @param sign the parameter providing the sign of the result798* @return a value with the magnitude of {@code magnitude}799* and the sign of {@code sign}.800* @author Joseph D. Darcy801* @since 1.5802* @deprecated Use StrictMath.copySign.803*/804@Deprecated805public static double copySign(double magnitude, double sign) {806return StrictMath.copySign(magnitude, sign);807}808809/**810* Returns the first floating-point argument with the sign of the811* second floating-point argument. For this method, a NaN812* {@code sign} argument is always treated as if it were813* positive.814*815* @param magnitude the parameter providing the magnitude of the result816* @param sign the parameter providing the sign of the result817* @return a value with the magnitude of {@code magnitude}818* and the sign of {@code sign}.819* @author Joseph D. Darcy820* @deprecated Use StrictMath.copySign.821*/822@Deprecated823public static float copySign(float magnitude, float sign) {824return StrictMath.copySign(magnitude, sign);825}826827/**828* Returns the size of an ulp of the argument. An ulp of a829* {@code double} value is the positive distance between this830* floating-point value and the {@code double} value next831* larger in magnitude. Note that for non-NaN <i>x</i>,832* <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.833*834* <p>Special Cases:835* <ul>836* <li> If the argument is NaN, then the result is NaN.837* <li> If the argument is positive or negative infinity, then the838* result is positive infinity.839* <li> If the argument is positive or negative zero, then the result is840* {@code Double.MIN_VALUE}.841* <li> If the argument is ±{@code Double.MAX_VALUE}, then842* the result is equal to 2<sup>971</sup>.843* </ul>844*845* @param d the floating-point value whose ulp is to be returned846* @return the size of an ulp of the argument847* @author Joseph D. Darcy848* @since 1.5849* @deprecated Use Math.ulp.850*/851@Deprecated852public static double ulp(double d) {853return Math.ulp(d);854}855856/**857* Returns the size of an ulp of the argument. An ulp of a858* {@code float} value is the positive distance between this859* floating-point value and the {@code float} value next860* larger in magnitude. Note that for non-NaN <i>x</i>,861* <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.862*863* <p>Special Cases:864* <ul>865* <li> If the argument is NaN, then the result is NaN.866* <li> If the argument is positive or negative infinity, then the867* result is positive infinity.868* <li> If the argument is positive or negative zero, then the result is869* {@code Float.MIN_VALUE}.870* <li> If the argument is ±{@code Float.MAX_VALUE}, then871* the result is equal to 2<sup>104</sup>.872* </ul>873*874* @param f the floating-point value whose ulp is to be returned875* @return the size of an ulp of the argument876* @author Joseph D. Darcy877* @since 1.5878* @deprecated Use Math.ulp.879*/880@Deprecated881public static float ulp(float f) {882return Math.ulp(f);883}884885/**886* Returns the signum function of the argument; zero if the argument887* is zero, 1.0 if the argument is greater than zero, -1.0 if the888* argument is less than zero.889*890* <p>Special Cases:891* <ul>892* <li> If the argument is NaN, then the result is NaN.893* <li> If the argument is positive zero or negative zero, then the894* result is the same as the argument.895* </ul>896*897* @param d the floating-point value whose signum is to be returned898* @return the signum function of the argument899* @author Joseph D. Darcy900* @since 1.5901* @deprecated Use Math.signum.902*/903@Deprecated904public static double signum(double d) {905return Math.signum(d);906}907908/**909* Returns the signum function of the argument; zero if the argument910* is zero, 1.0f if the argument is greater than zero, -1.0f if the911* argument is less than zero.912*913* <p>Special Cases:914* <ul>915* <li> If the argument is NaN, then the result is NaN.916* <li> If the argument is positive zero or negative zero, then the917* result is the same as the argument.918* </ul>919*920* @param f the floating-point value whose signum is to be returned921* @return the signum function of the argument922* @author Joseph D. Darcy923* @since 1.5924* @deprecated Use Math.signum.925*/926@Deprecated927public static float signum(float f) {928return Math.signum(f);929}930}931932933