Home
last modified time | relevance | path

Searched refs:Math (Results 1 – 25 of 348) sorted by relevance

12345678910>>...14

/libcore/luni/src/test/java/libcore/java/lang/
DOldAndroidMathTest.java23 import static java.lang.Math.PI;
27 private static final double HYP = Math.sqrt(2.0);
38 Assert.assertEquals(message, expected, actual, Math.ulp(expected)); in assertEquals()
46 Assert.assertEquals(message, expected, actual, Math.ulp(expected)); in assertEquals()
56 (Math.abs(-1908.8976) == 1908.8976)); in testAbsD()
58 (Math.abs(1908.8976) == 1908.8976)); in testAbsD()
64 (Math.abs(-1908.8976f) == 1908.8976f)); in testAbsF()
66 (Math.abs(1908.8976f) == 1908.8976f)); in testAbsF()
71 assertTrue("Incorrect int abs value", (Math.abs(-1908897) == 1908897)); in testAbsI()
72 assertTrue("Incorrect int abs value", (Math.abs(1908897) == 1908897)); in testAbsI()
[all …]
DIntrinsicTest.java56 Math.abs(1); in testMath_abs()
57 Math.class.getMethod("abs", int.class).invoke(null, 1); in testMath_abs()
58 Math.abs(1L); in testMath_abs()
59 Math.class.getMethod("abs", long.class).invoke(null, 1L); in testMath_abs()
60 Math.abs(1.0f); in testMath_abs()
61 Math.class.getMethod("abs", float.class).invoke(null, 1.0f); in testMath_abs()
62 Math.abs(1.0); in testMath_abs()
63 Math.class.getMethod("abs", double.class).invoke(null, 1.0); in testMath_abs()
93 Math.min(1, 2); in testMath_min()
94 Math.class.getMethod("min", int.class, int.class).invoke(null, 1, 2); in testMath_min()
[all …]
DMathTest.java49 assertEquals(expected, Math.addExact(a, b)); in testAddExactI()
60 assertEquals(expected, Math.subtractExact(a, b)); in testSubtractExactI()
72 assertEquals(expected, Math.multiplyExact(a, b)); in testMultiplyExactI()
83 assertEquals(expected, Math.incrementExact(a)); in testIncrementExactI()
94 assertEquals(expected, Math.decrementExact(a)); in testDecrementExactI()
105 assertEquals(expected, Math.negateExact(a)); in testNegateExactI()
138 assertEquals(expected, BigInteger.valueOf(Math.addExact(a, b))); in testAddExactL()
149 assertEquals(expected, BigInteger.valueOf(Math.subtractExact(a, b))); in testSubtractExactL()
160 assertEquals(expected, BigInteger.valueOf(Math.multiplyExact(a, b))); in testMultiplyExactL()
171 assertEquals(expected, BigInteger.valueOf(Math.incrementExact(a))); in testIncrementExactL()
[all …]
/libcore/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/
DMathTest.java22 double HYP = Math.sqrt(2.0);
38 (Math.abs(-1908.8976) == 1908.8976)); in test_absD()
40 (Math.abs(1908.8976) == 1908.8976)); in test_absD()
49 (Math.abs(-1908.8976f) == 1908.8976f)); in test_absF()
51 (Math.abs(1908.8976f) == 1908.8976f)); in test_absF()
59 assertTrue("Incorrect int abs value", (Math.abs(-1908897) == 1908897)); in test_absI()
60 assertTrue("Incorrect int abs value", (Math.abs(1908897) == 1908897)); in test_absI()
69 (Math.abs(-19088976000089L) == 19088976000089L)); in test_absJ()
71 (Math.abs(19088976000089L) == 19088976000089L)); in test_absJ()
79 double r = Math.cos(Math.acos(ADJ / HYP)); in test_acosD()
[all …]
/libcore/ojluni/src/test/java/lang/Math/
DMinMax.java29 package test.java.lang.Math;
55 test("Math.min(fnz, fnz)", Math.min(fnz, fnz), fnz); in testMinMax()
56 test("Math.min(fnz, fpz)", Math.min(fnz, fpz), fnz); in testMinMax()
57 test("Math.min(fpz, fnz)", Math.min(fpz, fnz), fnz); in testMinMax()
58 test("Math.min(fpz, fpz)", Math.min(fpz, fpz), fpz); in testMinMax()
60 test("Math.min(-1.0f, fnz)", Math.min(-1.0f, fnz), -1.0f); in testMinMax()
61 test("Math.min(-1.0f, fpz)", Math.min(-1.0f, fpz), -1.0f); in testMinMax()
62 test("Math.min(+1.0f, fnz)", Math.min(+1.0f, fnz), fnz); in testMinMax()
63 test("Math.min(+1.0f, fpz)", Math.min(+1.0f, fpz), fpz); in testMinMax()
64 test("Math.min(-1.0f, +1.0f)", Math.min(-1.0f, +1.0f), -1.0f); in testMinMax()
[all …]
DRint.java29 package test.java.lang.Math;
36 Tests.test("Math.rint", input, Math.rint(input), expected); in testRintCase()
37 Tests.test("Math.rint", -input, Math.rint(-input), -expected); in testRintCase()
46 double twoToThe52 = Math.scalb(1.0, 52); // 2^52 in testRint()
51 {Math.nextDown(Double.MIN_NORMAL), 0.0}, in testRint()
56 {Math.nextDown(0.5), 0.0}, in testRint()
58 {Math.nextUp(0.5), 1.0}, in testRint()
61 {Math.nextDown(1.0), 1.0}, in testRint()
63 {Math.nextUp(1.0), 1.0}, in testRint()
65 {Math.nextDown(1.5), 1.0}, in testRint()
[all …]
DCeilAndFloorTests.java29 package test.java.lang.Math;
36 Tests.test("Math.ceil", input, Math.ceil(input), expected); in testCeilCase()
41 Tests.test("Math.floor", input, Math.floor(input), expected); in testFloorCase()
67 double powerOfTwo = Math.scalb(1.0, i); in nearIntegerTests()
68 double neighborDown = Math.nextDown(powerOfTwo); in nearIntegerTests()
69 double neighborUp = Math.nextUp(powerOfTwo); in nearIntegerTests()
87 if (neighborDown == Math.rint(neighborDown)) { in nearIntegerTests()
98 if (neighborUp == Math.rint(neighborUp)) { in nearIntegerTests()
113 double neighborDown = Math.nextDown(d); in nearIntegerTests()
114 double neighborUp = Math.nextUp(d); in nearIntegerTests()
[all …]
DRoundTests.java23 package test.java.lang.Math;
52 Tests.test("Math.round", input, Math.round(input), expected); in testNearHalfCases()
74 Tests.test("Math.round", input, Math.round(input), expected); in testNearHalfCases()
80 Tests.test("Math.round", Float.NaN, Math.round(Float.NaN), 0.0F); in testSpecialCases()
82 Math.round(Float.POSITIVE_INFINITY), Integer.MAX_VALUE); in testSpecialCases()
84 Math.round(Float.NEGATIVE_INFINITY), Integer.MIN_VALUE); in testSpecialCases()
86 Math.round(-(float) Integer.MIN_VALUE), Integer.MAX_VALUE); in testSpecialCases()
88 Math.round((float) Integer.MIN_VALUE), Integer.MIN_VALUE); in testSpecialCases()
89 Tests.test("Math.round", 0F, Math.round(0F), 0.0F); in testSpecialCases()
91 Math.round(Float.MIN_VALUE), 0.0F); in testSpecialCases()
[all …]
DCubeRootTests.java34 package test.java.lang.Math;
57 Math.cbrt(input), expected); in testCubeRootCase()
59 Math.cbrt(minus_input), minus_expected); in testCubeRootCase()
104 testCubeRootCase(Math.scalb(1.0, 3 * i), Math.scalb(1.0, i)); in testCubeRoot()
109 testCubeRootCase(Math.scalb(1.0, 3 * i), Math.scalb(1.0, i)); in testCubeRoot()
117 Double.doubleToLongBits(Math.scalb(1.0, 55)) & in testCubeRoot()
120 Double.doubleToLongBits(Math.scalb(1.0, -55)) & in testCubeRoot()
179 double y1 = Math.cbrt(d); in testCubeRoot()
189 err_adjacent = StrictMath.pow(Math.nextUp(y1), 3) - d; in testCubeRoot()
191 err_adjacent = StrictMath.pow(Math.nextAfter(y1, 0.0), 3) - d; in testCubeRoot()
[all …]
DAbsPositiveZero.java23 package test.java.lang.Math;
45 Assert.assertTrue(isPositiveZero(Math.abs(-0.0d))); in testAbsPositiveZero()
46 Assert.assertTrue(isPositiveZero(Math.abs(+0.0d))); in testAbsPositiveZero()
48 Assert.assertEquals(Math.abs(Double.POSITIVE_INFINITY), Double.POSITIVE_INFINITY); in testAbsPositiveZero()
49 Assert.assertEquals(Math.abs(Double.NEGATIVE_INFINITY), Double.POSITIVE_INFINITY); in testAbsPositiveZero()
51 double dnanval = Math.abs(Double.NaN); in testAbsPositiveZero()
54 Assert.assertTrue(isPositiveZero(Math.abs(-0.0f))); in testAbsPositiveZero()
55 Assert.assertTrue(isPositiveZero(Math.abs(+0.0f))); in testAbsPositiveZero()
57 Assert.assertEquals(Math.abs(Float.POSITIVE_INFINITY), Float.POSITIVE_INFINITY); in testAbsPositiveZero()
58 Assert.assertEquals(Math.abs(Float.NEGATIVE_INFINITY), Float.POSITIVE_INFINITY); in testAbsPositiveZero()
[all …]
DLog10Tests.java30 package test.java.lang.Math;
49 Math.log10(input), expected); in testLog10Case()
101 input = Math.abs(input); in testLog10()
109 if (Math.abs(((result = Math.log10(input)) - expected) / Math.ulp(expected)) in testLog10()
117 if (Math.abs( in testLog10()
118 ((result = StrictMath.log10(input)) - expected) / Math.ulp(expected)) in testLog10()
140 neighbors[0] = Math.log10(1.0); in testLog10()
153 up = Math.nextUp(1.0); in testLog10()
154 down = Math.nextDown(1.0); in testLog10()
158 up = Math.nextUp(up); in testLog10()
[all …]
DPowTests.java30 package test.java.lang.Math;
60 Math.pow(input1, input2), strictMathExpected); in testPowCase()
72 Math.pow(input1, input2), expected); in testNonstrictPowCase()
115 /**/ -Math.PI, in testCrossProduct()
117 /**/ -Math.E, in testCrossProduct()
142 /**/ +Math.E, in testCrossProduct()
144 /**/ +Math.PI, in testCrossProduct()
178 if (Math.abs(x) > 1.0) { in testCrossProduct()
180 } else if (Math.abs(x) == 1.0) { in testCrossProduct()
182 } else if (Math.abs(x) < 1.0) { in testCrossProduct()
[all …]
DFusedMultiplyAddTests.java33 package test.java.lang.Math;
208 {1.0 + Math.ulp(1.0), 1.0 + Math.ulp(1.0), -1.0 - 2.0 * Math.ulp(1.0), in testSimpleD()
209 Math.ulp(1.0) * Math.ulp(1.0)}, in testSimpleD()
328 {1.0f + Math.ulp(1.0f), 1.0f + Math.ulp(1.0f), -1.0f - 2.0f * Math.ulp(1.0f), in testSimpleF()
329 Math.ulp(1.0f) * Math.ulp(1.0f)}, in testSimpleF()
344 Math.fma(input1, input2, input3), expected); in testFusedMacCase()
350 Math.fma(input2, input1, input3), expected); in testFusedMacCase()
357 Math.fma(input1, input2, input3), expected); in testFusedMacCase()
363 Math.fma(input2, input1, input3), expected); in testFusedMacCase()
DAbsTests.java23 package test.java.lang.Math;
51 testIntAbs(Math::abs, testCase[0], testCase[1]); in testInRangeIntAbs()
52 testIntAbs(Math::absExact, testCase[0], testCase[1]); in testInRangeIntAbs()
59 testIntAbs(Math::abs, Integer.MIN_VALUE, Integer.MIN_VALUE); in testIntMinValue()
62 assertThrows(ArithmeticException.class, () -> Math.absExact(Integer.MIN_VALUE)); in testIntMinValue()
91 testLongAbs(Math::abs, testCase[0], testCase[1]); in testInRangeLongAbs()
92 testLongAbs(Math::absExact, testCase[0], testCase[1]); in testInRangeLongAbs()
99 testLongAbs(Math::abs, Long.MIN_VALUE, Long.MIN_VALUE); in testLongMinValue()
102 assertThrows(ArithmeticException.class, () -> Math.absExact(Long.MIN_VALUE)); in testLongMinValue()
DHyperbolicTests.java30 package test.java.lang.Math;
268 double d = Math.scalb(2.0, i); in testSinh()
282 long transExpOvfl = Double.doubleToLongBits(Math.nextDown(709.7827128933841)); in testSinh()
346 double d = Math.scalb(2.0, i); in testSinh()
358 input, Math.sinh(input), in testSinhCaseWithTolerance()
361 -input, Math.sinh(-input), in testSinhCaseWithTolerance()
378 input, Math.sinh(input), in testSinhCaseWithUlpDiff()
381 -input, Math.sinh(-input), in testSinhCaseWithUlpDiff()
616 double d = Math.scalb(2.0, i); in testCosh()
630 long transExpOvfl = Double.doubleToLongBits(Math.nextDown(709.7827128933841)); in testCosh()
[all …]
DClamp.java24 package test.java.lang.Math;
71 int min = Math.toIntExact(test[1]); in testIntClamp()
72 int max = Math.toIntExact(test[2]); in testIntClamp()
73 int expected = Math.toIntExact(test[3]); in testIntClamp()
74 … checkEquals("(int) Math.clamp(" + value + ", " + min + ", " + max + ")", Math.clamp(value, min, m… in testIntClamp()
79 int min = Math.toIntExact(test[1]); in testIntClamp()
80 int max = Math.toIntExact(test[2]); in testIntClamp()
82 () -> Math.clamp(value, min, max)); in testIntClamp()
114 …checkEquals("(long) Math.clamp(" + value + ", " + min + ", " + max + ")", Math.clamp(value, min, m… in testLongClamp()
122 () -> Math.clamp(value, min, max)); in testLongClamp()
[all …]
DHypotTests.java34 package test.java.lang.Math;
58 result[0] = Math.abs(M * M - N * N); in pythagoreanTriple()
59 result[1] = Math.abs(2 * M * N); in pythagoreanTriple()
60 result[2] = Math.abs(M * M + N * N); in pythagoreanTriple()
95 double input = Math.scalb(2, i); in testHypot()
136 d = Math.scalb(d, Double.MAX_EXPONENT in testHypot()
162 double pc = Math.scalb(1.0, i); in testHypot()
165 pcNeighbors[1] = Math.nextDown(pc); in testHypot()
166 pcNeighbors[0] = Math.nextDown(pcNeighbors[1]); in testHypot()
167 pcNeighbors[3] = Math.nextUp(pc); in testHypot()
[all …]
DLog1pTests.java34 package test.java.lang.Math;
101 double d = Math.scalb(2, i); in testLog1p()
108 double d = Math.scalb(2, i); in testLog1p()
118 d = Math.scalb(d, -53 - Tests.ilogb(d)); in testLog1p()
145 double pc = StrictMath.pow(Math.E, i) - 1; in testLog1p()
148 pcNeighbors[1] = Math.nextDown(pc); in testLog1p()
149 pcNeighbors[0] = Math.nextDown(pcNeighbors[1]); in testLog1p()
150 pcNeighbors[3] = Math.nextUp(pc); in testLog1p()
151 pcNeighbors[4] = Math.nextUp(pcNeighbors[3]); in testLog1p()
154 pcNeighborsLog1p[j] = Math.log1p(pcNeighbors[j]); in testLog1p()
[all …]
DExpm1Tests.java44 package test.java.lang.Math;
84 double d = Math.scalb(2, i); in testExpm1()
102 double d = Math.scalb(2, i); in testExpm1()
118 double d = -Math.scalb(2, i); in testExpm1()
143 pcNeighbors[1] = Math.nextDown(pc); in testExpm1()
144 pcNeighbors[0] = Math.nextDown(pcNeighbors[1]); in testExpm1()
145 pcNeighbors[3] = Math.nextUp(pc); in testExpm1()
146 pcNeighbors[4] = Math.nextUp(pcNeighbors[3]); in testExpm1()
149 pcNeighborsExpm1[j] = Math.expm1(pcNeighbors[j]); in testExpm1()
202 input, mathOutput = Math.expm1(input), in testExpm1CaseWithUlpDiff()
/libcore/ojluni/src/main/java/java/lang/
DStrictMath.java496 int exponent = Math.getExponent(a); in floorOrCeil()
559 double sign = Math.copySign(1.0, a); // preserve sign info in rint()
560 a = Math.abs(a); in rint()
792 return Math.round(a); in round()
816 return Math.round(a); in round()
862 return Math.addExact(x, y); in addExact()
877 return Math.addExact(x, y); in addExact()
892 return Math.subtractExact(x, y); in subtractExact()
907 return Math.subtractExact(x, y); in subtractExact()
922 return Math.multiplyExact(x, y); in multiplyExact()
[all …]
/libcore/benchmarks/src/benchmarks/regression/
DMathBenchmark.java37 result = Math.abs(d); in timeAbsD()
45 result = Math.abs(f); in timeAbsF()
53 result = Math.abs(i); in timeAbsI()
61 result = Math.abs(l); in timeAbsL()
69 result = Math.acos(d); in timeAcos()
77 result = Math.asin(d); in timeAsin()
85 result = Math.atan(d); in timeAtan()
93 result = Math.atan2(3, 4); in timeAtan2()
101 result = Math.cbrt(d); in timeCbrt()
109 result = Math.ceil(d); in timeCeil()
[all …]
/libcore/ojluni/src/main/native/
DMath.c145 FAST_NATIVE_METHOD(Math, IEEEremainder, "(DD)D"),
146 FAST_NATIVE_METHOD(Math, acos, "(D)D"),
147 FAST_NATIVE_METHOD(Math, asin, "(D)D"),
148 FAST_NATIVE_METHOD(Math, atan, "(D)D"),
149 FAST_NATIVE_METHOD(Math, atan2, "(DD)D"),
150 FAST_NATIVE_METHOD(Math, cbrt, "(D)D"),
151 FAST_NATIVE_METHOD(Math, cos, "(D)D"),
152 FAST_NATIVE_METHOD(Math, ceil, "(D)D"),
153 FAST_NATIVE_METHOD(Math, cosh, "(D)D"),
154 FAST_NATIVE_METHOD(Math, exp, "(D)D"),
[all …]
/libcore/ojluni/src/main/java/sun/misc/
DFpUtils.java140 return Math.getExponent(d); in getExponent()
149 return Math.getExponent(f); in getExponent()
171 return Math.copySign(magnitude, sign); in rawCopySign()
192 return Math.copySign(magnitude, sign); in rawCopySign()
534 return Math.scalb(d, scale_factor); in scalb()
572 return Math.scalb(f, scale_factor); in scalb()
618 return Math.nextAfter(start, direction); in nextAfter()
664 return Math.nextAfter(start, direction); in nextAfter()
695 return Math.nextUp(d); in nextUp()
726 return Math.nextUp(f); in nextUp()
[all …]
/libcore/ojluni/src/main/java/java/time/
DPeriod.java201 return create(0, 0, Math.multiplyExact(weeks, 7)); in ofWeeks()
268 years = Math.toIntExact(unitAmount); in from()
270 months = Math.toIntExact(unitAmount); in from()
272 days = Math.toIntExact(unitAmount); in from()
335 days = Math.addExact(days, Math.multiplyExact(weeks, 7)); in parse()
355 return Math.multiplyExact(val, negate); in parseNumber()
624 Math.addExact(years, isoAmount.years), in plus()
625 Math.addExact(months, isoAmount.months), in plus()
626 Math.addExact(days, isoAmount.days)); in plus()
646 return create(Math.toIntExact(Math.addExact(years, yearsToAdd)), months, days); in plusYears()
[all …]
/libcore/ojluni/src/test/java/lang/StrictMath/
DExpTests.java70 {Math.nextUp(EXP_OVERFLOW_THRESH), Double.POSITIVE_INFINITY}, in testExp()
71 {Math.nextDown(EXP_UNDERFLOW_THRESH), +0.0}, in testExp()
95 EXP_OVERFLOW_THRESH - 512 * Math.ulp(EXP_OVERFLOW_THRESH), in testAgainstTranslit()
98 EXP_UNDERFLOW_THRESH - 512 * Math.ulp(EXP_UNDERFLOW_THRESH), in testAgainstTranslit()
107 Double.MIN_NORMAL - Math.ulp(Double.MIN_NORMAL) * 512, in testAgainstTranslit()
112 double ulp = Math.ulp(decisionPoint); in testAgainstTranslit()
119 testRange(x, Math.ulp(x), 100); in testAgainstTranslit()

12345678910>>...14