1 *java.lang.StrictMath* *StrictMath* The class StrictMath contains methods for pe
3 public final class StrictMath
4 extends |java.lang.Object|
6 |java.lang.StrictMath_Description|
7 |java.lang.StrictMath_Fields|
8 |java.lang.StrictMath_Constructors|
9 |java.lang.StrictMath_Methods|
11 ================================================================================
13 *java.lang.StrictMath_Fields*
14 |double_java.lang.StrictMath.E|
15 |double_java.lang.StrictMath.PI|
17 *java.lang.StrictMath_Methods*
18 |java.lang.StrictMath.abs(double)|Returns the absolute value of a double value.
19 |java.lang.StrictMath.abs(float)|Returns the absolute value of a float value.
20 |java.lang.StrictMath.abs(int)|Returns the absolute value of an int value..
21 |java.lang.StrictMath.abs(long)|Returns the absolute value of a long value.
22 |java.lang.StrictMath.acos(double)|Returns the arc cosine of a value; the retur
23 |java.lang.StrictMath.asin(double)|Returns the arc sine of a value; the returne
24 |java.lang.StrictMath.atan(double)|Returns the arc tangent of a value; the retu
25 |java.lang.StrictMath.atan2(double,double)|Returns the angle theta from the con
26 |java.lang.StrictMath.cbrt(double)|Returns the cube root of a double value.
27 |java.lang.StrictMath.ceil(double)|Returns the smallest (closest to negative in
28 |java.lang.StrictMath.copySign(double,double)|Returns the first floating-point
29 |java.lang.StrictMath.copySign(float,float)|Returns the first floating-point ar
30 |java.lang.StrictMath.cos(double)|Returns the trigonometric cosine of an angle.
31 |java.lang.StrictMath.cosh(double)|Returns the hyperbolic cosine of a double va
32 |java.lang.StrictMath.exp(double)|Returns Euler's number e raised to the power
33 |java.lang.StrictMath.expm1(double)|Returns ex-1.
34 |java.lang.StrictMath.floor(double)|Returns the largest (closest to positive in
35 |java.lang.StrictMath.getExponent(double)|Returns the unbiased exponent used in
36 |java.lang.StrictMath.getExponent(float)|Returns the unbiased exponent used in
37 |java.lang.StrictMath.hypot(double,double)|Returns sqrt(x2+y2) without interme
38 |java.lang.StrictMath.IEEEremainder(double,double)|Computes the remainder opera
39 |java.lang.StrictMath.log(double)|Returns the natural logarithm (base e) of a d
40 |java.lang.StrictMath.log10(double)|Returns the base 10 logarithm of a double v
41 |java.lang.StrictMath.log1p(double)|Returns the natural logarithm of the sum of
42 |java.lang.StrictMath.max(double,double)|Returns the greater of two double valu
43 |java.lang.StrictMath.max(float,float)|Returns the greater of two float values.
44 |java.lang.StrictMath.max(int,int)|Returns the greater of two int values.
45 |java.lang.StrictMath.max(long,long)|Returns the greater of two long values.
46 |java.lang.StrictMath.min(double,double)|Returns the smaller of two double valu
47 |java.lang.StrictMath.min(float,float)|Returns the smaller of two float values.
48 |java.lang.StrictMath.min(int,int)|Returns the smaller of two int values.
49 |java.lang.StrictMath.min(long,long)|Returns the smaller of two long values.
50 |java.lang.StrictMath.nextAfter(double,double)|Returns the floating-point numbe
51 |java.lang.StrictMath.nextAfter(float,double)|Returns the floating-point number
52 |java.lang.StrictMath.nextUp(double)|Returns the floating-point value adjacent
53 |java.lang.StrictMath.nextUp(float)|Returns the floating-point value adjacent t
54 |java.lang.StrictMath.pow(double,double)|Returns the value of the first argumen
55 |java.lang.StrictMath.random()|Returns a double value with a positive sign, gre
56 |java.lang.StrictMath.rint(double)|Returns the double value that is closest in
57 |java.lang.StrictMath.round(double)|Returns the closest long to the argument.
58 |java.lang.StrictMath.round(float)|Returns the closest int to the argument.
59 |java.lang.StrictMath.scalb(double,int)|Returnd 2scaleFactor rounded as if per
60 |java.lang.StrictMath.scalb(float,int)|Returnf 2scaleFactor rounded as if perf
61 |java.lang.StrictMath.signum(double)|Returns the signum function of the argumen
62 |java.lang.StrictMath.signum(float)|Returns the signum function of the argument
63 |java.lang.StrictMath.sin(double)|Returns the trigonometric sine of an angle.
64 |java.lang.StrictMath.sinh(double)|Returns the hyperbolic sine of a double valu
65 |java.lang.StrictMath.sqrt(double)|Returns the correctly rounded positive squar
66 |java.lang.StrictMath.tan(double)|Returns the trigonometric tangent of an angle
67 |java.lang.StrictMath.tanh(double)|Returns the hyperbolic tangent of a double v
68 |java.lang.StrictMath.toDegrees(double)|Converts an angle measured in radians t
69 |java.lang.StrictMath.toRadians(double)|Converts an angle measured in degrees t
70 |java.lang.StrictMath.ulp(double)|Returns the size of an ulp of the argument.
71 |java.lang.StrictMath.ulp(float)|Returns the size of an ulp of the argument.
73 *java.lang.StrictMath_Description*
75 The class StrictMath contains methods for performing basic numeric operations
76 such as the elementary exponential, logarithm, square root, and trigonometric
79 To help ensure portability of Java programs, the definitions of some of the
80 numeric functions in this package require that they produce the same results as
81 certain published algorithms. These algorithms are available from the
82 well-known network library netlib as the package "Freely Distributable Math
83 Library," fdlibm. These algorithms, which are written in the C programming
84 language, are then to be understood as executed with all floating-point
85 operations following the rules of Java floating-point arithmetic.
87 The Java math library is defined with respect to fdlibm version 5.3. Where
88 fdlibm provides more than one definition for a function (such as acos), use the
89 "IEEE 754 core function" version (residing in a file whose name begins with the
90 letter e). The methods which require fdlibm semantics are sin, cos, tan, asin,
91 acos, atan, exp, log, log10, cbrt, atan2, pow, sinh, cosh, tanh, hypot, expm1,
96 *double_java.lang.StrictMath.E*
98 The double value that is closer than any other to e, the base of the natural
102 *double_java.lang.StrictMath.PI*
104 The double value that is closer than any other to pi, the ratio of the
105 circumference of a circle to its diameter.
109 *java.lang.StrictMath.abs(double)*
111 public static double abs(double a)
113 Returns the absolute value of a double value. If the argument is not negative,
114 the argument is returned. If the argument is negative, the negation of the
115 argument is returned. Special cases: If the argument is positive zero or
116 negative zero, the result is positive zero. If the argument is infinite, the
117 result is positive infinity. If the argument is NaN, the result is NaN. In
118 other words, the result is the same as the value of the expression:
119 Double.longBitsToDouble((Double.doubleToLongBits(a)<<1)>>>1)
122 a - the argument whose absolute value is to be determined
124 Returns: the absolute value of the argument.
126 *java.lang.StrictMath.abs(float)*
128 public static float abs(float a)
130 Returns the absolute value of a float value. If the argument is not negative,
131 the argument is returned. If the argument is negative, the negation of the
132 argument is returned. Special cases: If the argument is positive zero or
133 negative zero, the result is positive zero. If the argument is infinite, the
134 result is positive infinity. If the argument is NaN, the result is NaN. In
135 other words, the result is the same as the value of the expression:
137 Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))
140 a - the argument whose absolute value is to be determined
142 Returns: the absolute value of the argument.
144 *java.lang.StrictMath.abs(int)*
146 public static int abs(int a)
148 Returns the absolute value of an int value.. If the argument is not negative,
149 the argument is returned. If the argument is negative, the negation of the
150 argument is returned.
152 Note that if the argument is equal to the value of Integer.MIN_VALUE, the most
153 negative representable int value, the result is that same value, which is
157 a - the argument whose absolute value is to be determined.
159 Returns: the absolute value of the argument.
161 *java.lang.StrictMath.abs(long)*
163 public static long abs(long a)
165 Returns the absolute value of a long value. If the argument is not negative,
166 the argument is returned. If the argument is negative, the negation of the
167 argument is returned.
169 Note that if the argument is equal to the value of Long.MIN_VALUE, the most
170 negative representable long value, the result is that same value, which is
174 a - the argument whose absolute value is to be determined.
176 Returns: the absolute value of the argument.
178 *java.lang.StrictMath.acos(double)*
180 public static native double acos(double a)
182 Returns the arc cosine of a value; the returned angle is in the range 0.0
183 through pi. Special case: If the argument is NaN or its absolute value is
184 greater than 1, then the result is NaN.
187 a - the value whose arc cosine is to be returned.
189 Returns: the arc cosine of the argument.
191 *java.lang.StrictMath.asin(double)*
193 public static native double asin(double a)
195 Returns the arc sine of a value; the returned angle is in the range -pi/2
196 through pi/2. Special cases: If the argument is NaN or its absolute value is
197 greater than 1, then the result is NaN. If the argument is zero, then the
198 result is a zero with the same sign as the argument.
201 a - the value whose arc sine is to be returned.
203 Returns: the arc sine of the argument.
205 *java.lang.StrictMath.atan(double)*
207 public static native double atan(double a)
209 Returns the arc tangent of a value; the returned angle is in the range -pi/2
210 through pi/2. Special cases: If the argument is NaN, then the result is NaN. If
211 the argument is zero, then the result is a zero with the same sign as the
215 a - the value whose arc tangent is to be returned.
217 Returns: the arc tangent of the argument.
219 *java.lang.StrictMath.atan2(double,double)*
221 public static native double atan2(
225 Returns the angle theta from the conversion of rectangular coordinates (x,y) to
226 polar coordinates (r,theta). This method computes the phase theta by computing
227 an arc tangent of y/x in the range of -pi to pi. Special cases: If either
228 argument is NaN, then the result is NaN. If the first argument is positive zero
229 and the second argument is positive, or the first argument is positive and
230 finite and the second argument is positive infinity, then the result is
231 positive zero. If the first argument is negative zero and the second argument
232 is positive, or the first argument is negative and finite and the second
233 argument is positive infinity, then the result is negative zero. If the first
234 argument is positive zero and the second argument is negative, or the first
235 argument is positive and finite and the second argument is negative infinity,
236 then the result is the double value closest to pi. If the first argument is
237 negative zero and the second argument is negative, or the first argument is
238 negative and finite and the second argument is negative infinity, then the
239 result is the double value closest to -pi. If the first argument is positive
240 and the second argument is positive zero or negative zero, or the first
241 argument is positive infinity and the second argument is finite, then the
242 result is the double value closest to pi/2. If the first argument is negative
243 and the second argument is positive zero or negative zero, or the first
244 argument is negative infinity and the second argument is finite, then the
245 result is the double value closest to -pi/2. If both arguments are positive
246 infinity, then the result is the double value closest to pi/4. If the first
247 argument is positive infinity and the second argument is negative infinity,
248 then the result is the double value closest to 3*pi/4. If the first argument is
249 negative infinity and the second argument is positive infinity, then the result
250 is the double value closest to -pi/4. If both arguments are negative infinity,
251 then the result is the double value closest to -3*pi/4.
254 y - the ordinate coordinate
255 x - the abscissa coordinate
257 Returns: the theta component of the point (r,theta) in polar coordinates that
258 corresponds to the point (x,y) in Cartesian coordinates.
260 *java.lang.StrictMath.cbrt(double)*
262 public static native double cbrt(double a)
264 Returns the cube root of a double value. For positive finite x, cbrt(-x) ==
265 -cbrt(x); that is, the cube root of a negative value is the negative of the
266 cube root of that value's magnitude. Special cases:
270 If the argument is NaN, then the result is NaN.
272 If the argument is infinite, then the result is an infinity with the same sign
275 If the argument is zero, then the result is a zero with the same sign as the
283 Returns: the cube root of a.
285 *java.lang.StrictMath.ceil(double)*
287 public static native double ceil(double a)
289 Returns the smallest (closest to negative infinity) double value that is
290 greater than or equal to the argument and is equal to a mathematical integer.
291 Special cases: If the argument value is already equal to a mathematical
292 integer, then the result is the same as the argument. If the argument is NaN or
293 an infinity or positive zero or negative zero, then the result is the same as
294 the argument. If the argument value is less than zero but greater than -1.0,
295 then the result is negative zero. Note that the value of StrictMath.ceil(x) is
296 exactly the value of -StrictMath.floor(-x).
301 Returns: the smallest (closest to negative infinity) floating-point value that is
302 greater than or equal to the argument and is equal to a
303 mathematical integer.
305 *java.lang.StrictMath.copySign(double,double)*
307 public static double copySign(
311 Returns the first floating-point argument with the sign of the second
312 floating-point argument. For this method, a NaNsignargument is always treated
313 as if it were positive.
316 magnitude - the parameter providing the magnitude of the result
317 sign - the parameter providing the sign of the result
319 Returns: a value with the magnitude of {@code magnitude} and the sign of {@code sign}.
321 *java.lang.StrictMath.copySign(float,float)*
323 public static float copySign(
327 Returns the first floating-point argument with the sign of the second
328 floating-point argument. For this method, a NaNsignargument is always treated
329 as if it were positive.
332 magnitude - the parameter providing the magnitude of the result
333 sign - the parameter providing the sign of the result
335 Returns: a value with the magnitude of {@code magnitude} and the sign of {@code sign}.
337 *java.lang.StrictMath.cos(double)*
339 public static native double cos(double a)
341 Returns the trigonometric cosine of an angle. Special cases: If the argument is
342 NaN or an infinity, then the result is NaN.
345 a - an angle, in radians.
347 Returns: the cosine of the argument.
349 *java.lang.StrictMath.cosh(double)*
351 public static native double cosh(double x)
353 Returns the hyperbolic cosine of a double value. The hyperbolic cosine of x is
354 defined to be (ex+e-x)/2 where e is Euler's number(|java.lang.Math|) .
358 If the argument is NaN, then the result is NaN.
360 If the argument is infinite, then the result is positive infinity.
362 If the argument is zero, then the result is 1.0.
367 x - The number whose hyperbolic cosine is to be returned.
369 Returns: The hyperbolic cosine of x.
371 *java.lang.StrictMath.exp(double)*
373 public static native double exp(double a)
375 Returns Euler's number e raised to the power of a double value. Special cases:
376 If the argument is NaN, the result is NaN. If the argument is positive
377 infinity, then the result is positive infinity. If the argument is negative
378 infinity, then the result is positive zero.
381 a - the exponent to raise e to.
383 Returns: the value ea, where e is the base of the natural logarithms.
385 *java.lang.StrictMath.expm1(double)*
387 public static native double expm1(double x)
389 Returns ex-1. Note that for values of x near 0, the exact sum of expm1(x)+1 is
390 much closer to the true result of ex than exp(x).
394 If the argument is NaN, the result is NaN.
396 If the argument is positive infinity, then the result is positive infinity.
398 If the argument is negative infinity, then the result is -1.0.
400 If the argument is zero, then the result is a zero with the same sign as the
406 x - the exponent to raise e to in the computation of ex-1.
408 Returns: the value ex-1.
410 *java.lang.StrictMath.floor(double)*
412 public static native double floor(double a)
414 Returns the largest (closest to positive infinity) double value that is less
415 than or equal to the argument and is equal to a mathematical integer. Special
416 cases: If the argument value is already equal to a mathematical integer, then
417 the result is the same as the argument. If the argument is NaN or an infinity
418 or positive zero or negative zero, then the result is the same as the argument.
423 Returns: the largest (closest to positive infinity) floating-point value that less than
424 or equal to the argument and is equal to a mathematical integer.
426 *java.lang.StrictMath.getExponent(double)*
428 public static int getExponent(double d)
430 Returns the unbiased exponent used in the representation of adouble. Special
433 If the argument is NaN or infinite, then the result is (|java.lang.Double|) +
434 1. If the argument is zero or subnormal, then the result is
435 (|java.lang.Double|) -1.
438 d - a {@code double} value
440 *java.lang.StrictMath.getExponent(float)*
442 public static int getExponent(float f)
444 Returns the unbiased exponent used in the representation of afloat. Special
447 If the argument is NaN or infinite, then the result is (|java.lang.Float|) + 1.
448 If the argument is zero or subnormal, then the result is (|java.lang.Float|)
452 f - a {@code float} value
454 *java.lang.StrictMath.hypot(double,double)*
456 public static native double hypot(
460 Returns sqrt(x2+y2) without intermediate overflow or underflow.
464 If either argument is infinite, then the result is positive infinity.
466 If either argument is NaN and neither argument is infinite, then the result is
475 Returns: sqrt(x2+y2) without intermediate overflow or underflow
477 *java.lang.StrictMath.IEEEremainder(double,double)*
479 public static native double IEEEremainder(
483 Computes the remainder operation on two arguments as prescribed by the IEEE 754
484 standard. The remainder value is mathematically equal to f1-f2n, where n is the
485 mathematical integer closest to the exact mathematical value of the quotient
486 f1/f2, and if two mathematical integers are equally close to f1/f2, then n is
487 the integer that is even. If the remainder is zero, its sign is the same as the
488 sign of the first argument. Special cases: If either argument is NaN, or the
489 first argument is infinite, or the second argument is positive zero or negative
490 zero, then the result is NaN. If the first argument is finite and the second
491 argument is infinite, then the result is the same as the first argument.
497 Returns: the remainder when f1 is divided by f2.
499 *java.lang.StrictMath.log(double)*
501 public static native double log(double a)
503 Returns the natural logarithm (base e) of a double value. Special cases: If the
504 argument is NaN or less than zero, then the result is NaN. If the argument is
505 positive infinity, then the result is positive infinity. If the argument is
506 positive zero or negative zero, then the result is negative infinity.
511 Returns: the value lna, the natural logarithm of a.
513 *java.lang.StrictMath.log10(double)*
515 public static native double log10(double a)
517 Returns the base 10 logarithm of a double value. Special cases:
519 If the argument is NaN or less than zero, then the result is NaN. If the
520 argument is positive infinity, then the result is positive infinity. If the
521 argument is positive zero or negative zero, then the result is negative
522 infinity. If the argument is equal to 10n for integer n, then the result is n.
527 Returns: the base 10 logarithm of a.
529 *java.lang.StrictMath.log1p(double)*
531 public static native double log1p(double x)
533 Returns the natural logarithm of the sum of the argument and 1. Note that for
534 small values x, the result of log1p(x) is much closer to the true result of
535 ln(1 + x) than the floating-point evaluation of log(1.0+x).
541 If the argument is NaN or less than -1, then the result is NaN.
543 If the argument is positive infinity, then the result is positive infinity.
545 If the argument is negative one, then the result is negative infinity.
547 If the argument is zero, then the result is a zero with the same sign as the
555 Returns: the value ln(x+1), the natural log of x+1
557 *java.lang.StrictMath.max(double,double)*
559 public static double max(
563 Returns the greater of two double values. That is, the result is the argument
564 closer to positive infinity. If the arguments have the same value, the result
565 is that same value. If either value is NaN, then the result is NaN. Unlike the
566 numerical comparison operators, this method considers negative zero to be
567 strictly smaller than positive zero. If one argument is positive zero and the
568 other negative zero, the result is positive zero.
572 b - another argument.
574 Returns: the larger of a and b.
576 *java.lang.StrictMath.max(float,float)*
578 public static float max(
582 Returns the greater of two float values. That is, the result is the argument
583 closer to positive infinity. If the arguments have the same value, the result
584 is that same value. If either value is NaN, then the result is NaN. Unlike the
585 numerical comparison operators, this method considers negative zero to be
586 strictly smaller than positive zero. If one argument is positive zero and the
587 other negative zero, the result is positive zero.
591 b - another argument.
593 Returns: the larger of a and b.
595 *java.lang.StrictMath.max(int,int)*
597 public static int max(
601 Returns the greater of two int values. That is, the result is the argument
602 closer to the value of Integer.MAX_VALUE. If the arguments have the same value,
603 the result is that same value.
607 b - another argument.
609 Returns: the larger of a and b.
611 *java.lang.StrictMath.max(long,long)*
613 public static long max(
617 Returns the greater of two long values. That is, the result is the argument
618 closer to the value of Long.MAX_VALUE. If the arguments have the same value,
619 the result is that same value.
623 b - another argument.
625 Returns: the larger of a and b.
627 *java.lang.StrictMath.min(double,double)*
629 public static double min(
633 Returns the smaller of two double values. That is, the result is the value
634 closer to negative infinity. If the arguments have the same value, the result
635 is that same value. If either value is NaN, then the result is NaN. Unlike the
636 numerical comparison operators, this method considers negative zero to be
637 strictly smaller than positive zero. If one argument is positive zero and the
638 other is negative zero, the result is negative zero.
642 b - another argument.
644 Returns: the smaller of a and b.
646 *java.lang.StrictMath.min(float,float)*
648 public static float min(
652 Returns the smaller of two float values. That is, the result is the value
653 closer to negative infinity. If the arguments have the same value, the result
654 is that same value. If either value is NaN, then the result is NaN. Unlike the
655 numerical comparison operators, this method considers negative zero to be
656 strictly smaller than positive zero. If one argument is positive zero and the
657 other is negative zero, the result is negative zero.
661 b - another argument.
663 Returns: the smaller of a and b.
665 *java.lang.StrictMath.min(int,int)*
667 public static int min(
671 Returns the smaller of two int values. That is, the result the argument closer
672 to the value of Integer.MIN_VALUE. If the arguments have the same value, the
673 result is that same value.
677 b - another argument.
679 Returns: the smaller of a and b.
681 *java.lang.StrictMath.min(long,long)*
683 public static long min(
687 Returns the smaller of two long values. That is, the result is the argument
688 closer to the value of Long.MIN_VALUE. If the arguments have the same value,
689 the result is that same value.
693 b - another argument.
695 Returns: the smaller of a and b.
697 *java.lang.StrictMath.nextAfter(double,double)*
699 public static double nextAfter(
703 Returns the floating-point number adjacent to the first argument in the
704 direction of the second argument. If both arguments compare as equal the second
705 argument is returned.
709 If either argument is a NaN, then NaN is returned.
711 If both arguments are signed zeros,directionis returned unchanged (as implied
712 by the requirement of returning the second argument if the arguments compare as
715 Ifstartis (|java.lang.Double|) anddirectionhas a value such that the result
716 should have a smaller magnitude, then a zero with the same sign asstartis
719 Ifstartis infinite anddirectionhas a value such that the result should have a
720 smaller magnitude, (|java.lang.Double|) with the same sign asstartis returned.
722 Ifstartis equal to (|java.lang.Double|) anddirectionhas a value such that the
723 result should have a larger magnitude, an infinity with same sign asstartis
727 start - starting floating-point value
728 direction - value indicating which of {@code start}'s neighbors or {@code start} should be
731 Returns: The floating-point number adjacent to {@code start} in the direction of {@code
734 *java.lang.StrictMath.nextAfter(float,double)*
736 public static float nextAfter(
740 Returns the floating-point number adjacent to the first argument in the
741 direction of the second argument. If both arguments compare as equal a value
742 equivalent to the second argument is returned.
746 If either argument is a NaN, then NaN is returned.
748 If both arguments are signed zeros, a value equivalent todirectionis returned.
750 Ifstartis (|java.lang.Float|) anddirectionhas a value such that the result
751 should have a smaller magnitude, then a zero with the same sign asstartis
754 Ifstartis infinite anddirectionhas a value such that the result should have a
755 smaller magnitude, (|java.lang.Float|) with the same sign asstartis returned.
757 Ifstartis equal to (|java.lang.Float|) anddirectionhas a value such that the
758 result should have a larger magnitude, an infinity with same sign asstartis
762 start - starting floating-point value
763 direction - value indicating which of {@code start}'s neighbors or {@code start} should be
766 Returns: The floating-point number adjacent to {@code start} in the direction of {@code
769 *java.lang.StrictMath.nextUp(double)*
771 public static double nextUp(double d)
773 Returns the floating-point value adjacent todin the direction of positive
774 infinity. This method is semantically equivalent tonextAfter(d,
775 Double.POSITIVE_INFINITY); however, anextUpimplementation may run faster than
776 its equivalentnextAftercall.
780 If the argument is NaN, the result is NaN.
782 If the argument is positive infinity, the result is positive infinity.
784 If the argument is zero, the result is (|java.lang.Double|)
787 d - starting floating-point value
789 Returns: The adjacent floating-point value closer to positive infinity.
791 *java.lang.StrictMath.nextUp(float)*
793 public static float nextUp(float f)
795 Returns the floating-point value adjacent tofin the direction of positive
796 infinity. This method is semantically equivalent tonextAfter(f,
797 Float.POSITIVE_INFINITY); however, anextUpimplementation may run faster than
798 its equivalentnextAftercall.
802 If the argument is NaN, the result is NaN.
804 If the argument is positive infinity, the result is positive infinity.
806 If the argument is zero, the result is (|java.lang.Float|)
809 f - starting floating-point value
811 Returns: The adjacent floating-point value closer to positive infinity.
813 *java.lang.StrictMath.pow(double,double)*
815 public static native double pow(
819 Returns the value of the first argument raised to the power of the second
820 argument. Special cases:
822 If the second argument is positive or negative zero, then the result is 1.0. If
823 the second argument is 1.0, then the result is the same as the first argument.
824 If the second argument is NaN, then the result is NaN. If the first argument is
825 NaN and the second argument is nonzero, then the result is NaN.
829 the absolute value of the first argument is greater than 1 and the second
830 argument is positive infinity, or the absolute value of the first argument is
831 less than 1 and the second argument is negative infinity,
833 then the result is positive infinity.
837 the absolute value of the first argument is greater than 1 and the second
838 argument is negative infinity, or the absolute value of the first argument is
839 less than 1 and the second argument is positive infinity,
841 then the result is positive zero.
843 If the absolute value of the first argument equals 1 and the second argument is
844 infinite, then the result is NaN.
848 the first argument is positive zero and the second argument is greater than
849 zero, or the first argument is positive infinity and the second argument is
852 then the result is positive zero.
856 the first argument is positive zero and the second argument is less than zero,
857 or the first argument is positive infinity and the second argument is greater
860 then the result is positive infinity.
864 the first argument is negative zero and the second argument is greater than
865 zero but not a finite odd integer, or the first argument is negative infinity
866 and the second argument is less than zero but not a finite odd integer,
868 then the result is positive zero.
872 the first argument is negative zero and the second argument is a positive
873 finite odd integer, or the first argument is negative infinity and the second
874 argument is a negative finite odd integer,
876 then the result is negative zero.
880 the first argument is negative zero and the second argument is less than zero
881 but not a finite odd integer, or the first argument is negative infinity and
882 the second argument is greater than zero but not a finite odd integer,
884 then the result is positive infinity.
888 the first argument is negative zero and the second argument is a negative
889 finite odd integer, or the first argument is negative infinity and the second
890 argument is a positive finite odd integer,
892 then the result is negative infinity.
894 If the first argument is finite and less than zero
896 if the second argument is a finite even integer, the result is equal to the
897 result of raising the absolute value of the first argument to the power of the
900 if the second argument is a finite odd integer, the result is equal to the
901 negative of the result of raising the absolute value of the first argument to
902 the power of the second argument
904 if the second argument is finite and not an integer, then the result is NaN.
906 If both arguments are integers, then the result is exactly equal to the
907 mathematical result of raising the first argument to the power of the second
908 argument if that result can in fact be represented exactly as a double value.
910 (In the foregoing descriptions, a floating-point value is considered to be an
911 integer if and only if it is finite and a fixed point of the method
912 <tt>ceil</tt>(|java.lang.StrictMath|) or, equivalently, a fixed point of the
913 method <tt>floor</tt>(|java.lang.StrictMath|) . A value is a fixed point of a
914 one-argument method if and only if the result of applying the method to the
915 value is equal to the value.)
921 Returns: the value ab.
923 *java.lang.StrictMath.random()*
925 public static double random()
927 Returns a double value with a positive sign, greater than or equal to 0.0 and
928 less than 1.0. Returned values are chosen pseudorandomly with (approximately)
929 uniform distribution from that range.
931 When this method is first called, it creates a single new pseudorandom-number
932 generator, exactly as if by the expression
934 new java.util.Random This new pseudorandom-number generator is used thereafter
935 for all calls to this method and is used nowhere else.
937 This method is properly synchronized to allow correct use by more than one
938 thread. However, if many threads need to generate pseudorandom numbers at a
939 great rate, it may reduce contention for each thread to have its own
940 pseudorandom number generator.
944 Returns: a pseudorandom double greater than or equal to 0.0 and less than 1.0.
946 *java.lang.StrictMath.rint(double)*
948 public static double rint(double a)
950 Returns the double value that is closest in value to the argument and is equal
951 to a mathematical integer. If two double values that are mathematical integers
952 are equally close to the value of the argument, the result is the integer value
953 that is even. Special cases: If the argument value is already equal to a
954 mathematical integer, then the result is the same as the argument. If the
955 argument is NaN or an infinity or positive zero or negative zero, then the
956 result is the same as the argument.
961 Returns: the closest floating-point value to a that is equal to a mathematical integer.
963 *java.lang.StrictMath.round(double)*
965 public static long round(double a)
967 Returns the closest long to the argument. The result is rounded to an integer
968 by adding 1/2, taking the floor of the result, and casting the result to type
969 long. In other words, the result is equal to the value of the expression:
971 (long)Math.floor(a + 0.5d)
973 Special cases: If the argument is NaN, the result is 0. If the argument is
974 negative infinity or any value less than or equal to the value of
975 Long.MIN_VALUE, the result is equal to the value of Long.MIN_VALUE. If the
976 argument is positive infinity or any value greater than or equal to the value
977 of Long.MAX_VALUE, the result is equal to the value of Long.MAX_VALUE.
980 a - a floating-point value to be rounded to a long.
982 Returns: the value of the argument rounded to the nearest long value.
984 *java.lang.StrictMath.round(float)*
986 public static int round(float a)
988 Returns the closest int to the argument. The result is rounded to an integer by
989 adding 1/2, taking the floor of the result, and casting the result to type int.
990 In other words, the result is equal to the value of the expression:
992 (int)Math.floor(a + 0.5f)
994 Special cases: If the argument is NaN, the result is 0. If the argument is
995 negative infinity or any value less than or equal to the value of
996 Integer.MIN_VALUE, the result is equal to the value of Integer.MIN_VALUE. If
997 the argument is positive infinity or any value greater than or equal to the
998 value of Integer.MAX_VALUE, the result is equal to the value of
1002 a - a floating-point value to be rounded to an integer.
1004 Returns: the value of the argument rounded to the nearest int value.
1006 *java.lang.StrictMath.scalb(double,int)*
1008 public static double scalb(
1012 Returnd 2scaleFactor rounded as if performed by a single correctly rounded
1013 floating-point multiply to a member of the double value set. See the Java
1014 Language Specification for a discussion of floating-point value sets. If the
1015 exponent of the result is between (|java.lang.Double|) and (|java.lang.Double|)
1016 , the answer is calculated exactly. If the exponent of the result would be
1017 larger thanDouble.MAX_EXPONENT, an infinity is returned. Note that if the
1018 result is subnormal, precision may be lost; that is, whenscalb(x, n)is
1019 subnormal,scalb(scalb(x, n), -n)may not equal x. When the result is non-NaN,
1020 the result has the same sign asd.
1024 If the first argument is NaN, NaN is returned. If the first argument is
1025 infinite, then an infinity of the same sign is returned. If the first argument
1026 is zero, then a zero of the same sign is returned.
1029 d - number to be scaled by a power of two.
1030 scaleFactor - power of 2 used to scale {@code d}
1032 Returns: {@code d} 2{@code scaleFactor}
1034 *java.lang.StrictMath.scalb(float,int)*
1036 public static float scalb(
1040 Returnf 2scaleFactor rounded as if performed by a single correctly rounded
1041 floating-point multiply to a member of the float value set. See the Java
1042 Language Specification for a discussion of floating-point value sets. If the
1043 exponent of the result is between (|java.lang.Float|) and (|java.lang.Float|) ,
1044 the answer is calculated exactly. If the exponent of the result would be larger
1045 thanFloat.MAX_EXPONENT, an infinity is returned. Note that if the result is
1046 subnormal, precision may be lost; that is, whenscalb(x, n)is
1047 subnormal,scalb(scalb(x, n), -n)may not equal x. When the result is non-NaN,
1048 the result has the same sign asf.
1052 If the first argument is NaN, NaN is returned. If the first argument is
1053 infinite, then an infinity of the same sign is returned. If the first argument
1054 is zero, then a zero of the same sign is returned.
1057 f - number to be scaled by a power of two.
1058 scaleFactor - power of 2 used to scale {@code f}
1060 Returns: {@code f} 2{@code scaleFactor}
1062 *java.lang.StrictMath.signum(double)*
1064 public static double signum(double d)
1066 Returns the signum function of the argument; zero if the argument is zero, 1.0
1067 if the argument is greater than zero, -1.0 if the argument is less than zero.
1071 If the argument is NaN, then the result is NaN. If the argument is positive
1072 zero or negative zero, then the result is the same as the argument.
1075 d - the floating-point value whose signum is to be returned
1077 Returns: the signum function of the argument
1079 *java.lang.StrictMath.signum(float)*
1081 public static float signum(float f)
1083 Returns the signum function of the argument; zero if the argument is zero, 1.0f
1084 if the argument is greater than zero, -1.0f if the argument is less than zero.
1088 If the argument is NaN, then the result is NaN. If the argument is positive
1089 zero or negative zero, then the result is the same as the argument.
1092 f - the floating-point value whose signum is to be returned
1094 Returns: the signum function of the argument
1096 *java.lang.StrictMath.sin(double)*
1098 public static native double sin(double a)
1100 Returns the trigonometric sine of an angle. Special cases: If the argument is
1101 NaN or an infinity, then the result is NaN. If the argument is zero, then the
1102 result is a zero with the same sign as the argument.
1105 a - an angle, in radians.
1107 Returns: the sine of the argument.
1109 *java.lang.StrictMath.sinh(double)*
1111 public static native double sinh(double x)
1113 Returns the hyperbolic sine of a double value. The hyperbolic sine of x is
1114 defined to be (ex-e-x)/2 where e is Euler's number(|java.lang.Math|) .
1118 If the argument is NaN, then the result is NaN.
1120 If the argument is infinite, then the result is an infinity with the same sign
1123 If the argument is zero, then the result is a zero with the same sign as the
1129 x - The number whose hyperbolic sine is to be returned.
1131 Returns: The hyperbolic sine of x.
1133 *java.lang.StrictMath.sqrt(double)*
1135 public static native double sqrt(double a)
1137 Returns the correctly rounded positive square root of a double value. Special
1138 cases: If the argument is NaN or less than zero, then the result is NaN. If the
1139 argument is positive infinity, then the result is positive infinity. If the
1140 argument is positive zero or negative zero, then the result is the same as the
1141 argument. Otherwise, the result is the double value closest to the true
1142 mathematical square root of the argument value.
1147 Returns: the positive square root of a.
1149 *java.lang.StrictMath.tan(double)*
1151 public static native double tan(double a)
1153 Returns the trigonometric tangent of an angle. Special cases: If the argument
1154 is NaN or an infinity, then the result is NaN. If the argument is zero, then
1155 the result is a zero with the same sign as the argument.
1158 a - an angle, in radians.
1160 Returns: the tangent of the argument.
1162 *java.lang.StrictMath.tanh(double)*
1164 public static native double tanh(double x)
1166 Returns the hyperbolic tangent of a double value. The hyperbolic tangent of x
1167 is defined to be (ex-e-x)/(ex+e-x), in other words,
1168 sinh(<i>x</i>)(|java.lang.Math|) / cosh(<i>x</i>)(|java.lang.Math|) . Note that
1169 the absolute value of the exact tanh is always less than 1.
1173 If the argument is NaN, then the result is NaN.
1175 If the argument is zero, then the result is a zero with the same sign as the
1178 If the argument is positive infinity, then the result is +1.0.
1180 If the argument is negative infinity, then the result is -1.0.
1185 x - The number whose hyperbolic tangent is to be returned.
1187 Returns: The hyperbolic tangent of x.
1189 *java.lang.StrictMath.toDegrees(double)*
1191 public static double toDegrees(double angrad)
1193 Converts an angle measured in radians to an approximately equivalent angle
1194 measured in degrees. The conversion from radians to degrees is generally
1195 inexact; users should not expect cos(toRadians(90.0)) to exactly equal 0.0.
1198 angrad - an angle, in radians
1200 Returns: the measurement of the angle angrad in degrees.
1202 *java.lang.StrictMath.toRadians(double)*
1204 public static double toRadians(double angdeg)
1206 Converts an angle measured in degrees to an approximately equivalent angle
1207 measured in radians. The conversion from degrees to radians is generally
1211 angdeg - an angle, in degrees
1213 Returns: the measurement of the angle angdeg in radians.
1215 *java.lang.StrictMath.ulp(double)*
1217 public static double ulp(double d)
1219 Returns the size of an ulp of the argument. An ulp of a double value is the
1220 positive distance between this floating-point value and the double value next
1221 larger in magnitude. Note that for non-NaN x, ulp(-x) == ulp(x).
1225 If the argument is NaN, then the result is NaN. If the argument is positive or
1226 negative infinity, then the result is positive infinity. If the argument is
1227 positive or negative zero, then the result is Double.MIN_VALUE. If the argument
1228 is Double.MAX_VALUE, then the result is equal to 2971.
1231 d - the floating-point value whose ulp is to be returned
1233 Returns: the size of an ulp of the argument
1235 *java.lang.StrictMath.ulp(float)*
1237 public static float ulp(float f)
1239 Returns the size of an ulp of the argument. An ulp of a float value is the
1240 positive distance between this floating-point value and the float value next
1241 larger in magnitude. Note that for non-NaN x, ulp(-x) == ulp(x).
1245 If the argument is NaN, then the result is NaN. If the argument is positive or
1246 negative infinity, then the result is positive infinity. If the argument is
1247 positive or negative zero, then the result is Float.MIN_VALUE. If the argument
1248 is Float.MAX_VALUE, then the result is equal to 2104.
1251 f - the floating-point value whose ulp is to be returned
1253 Returns: the size of an ulp of the argument