Commit 13a6ccd6 authored by Stephanie Gawroriski's avatar Stephanie Gawroriski
Browse files

Add strictfp to all Math and FDMLMath methods; Use constants in some places for math.

parent 3391fd33
Pipeline #109249 passed with stages
in 6 minutes and 39 seconds
......@@ -107,7 +107,7 @@ public final strictfp class FDMLMath
* @since 2018/11/02
*/
@ImplementationNote("Source http://www.netlib.org/fdlibm/e_log.c")
public static double log(double __v)
public static strictfp double log(double __v)
{
double hfsq, f, s, z, r, w, t1, t2, dk;
int k, hx, i, j;
......@@ -124,11 +124,11 @@ public final strictfp class FDMLMath
{
// log(+-0)=-inf
if (((hx & 0x7FFFFFFF) | uulx) == 0)
return -FDMLMath._TWO54 / FDMLMath._ZERO;
return Double.NEGATIVE_INFINITY;
// log(-#) = NaN
if (hx < 0)
return (__v - __v) / FDMLMath._ZERO;
return Double.NaN;
// subnormal number, scale up __v
k -= 54;
......@@ -210,7 +210,7 @@ public final strictfp class FDMLMath
* @since 2018/11/02
*/
@ImplementationNote("Source: http://www.netlib.org/fdlibm/e_sqrt.c")
public static double sqrt(double __v)
public static strictfp double sqrt(double __v)
{
double z;
int uur, uut1, uus1, uuix1, uuq1;
......@@ -370,7 +370,7 @@ public final strictfp class FDMLMath
* @return The double value.
* @since 2018/11/03
*/
private static final double __compose(int __hi, int __lo)
private static final strictfp double __compose(int __hi, int __lo)
{
return Double.longBitsToDouble(
(((long)__hi & 0xFFFFFFFFL) << 32) |
......@@ -384,7 +384,7 @@ public final strictfp class FDMLMath
* @return The high word of the double.
* @since 2018/11/03
*/
private static final int __hi(double __v)
private static final strictfp int __hi(double __v)
{
return (int)(Double.doubleToRawLongBits(__v) >>> 32);
}
......@@ -396,7 +396,7 @@ public final strictfp class FDMLMath
* @return The low word of the double.
* @since 2018/11/03
*/
private static final int __lo(double __v)
private static final strictfp int __lo(double __v)
{
return (int)(Double.doubleToRawLongBits(__v));
}
......
......@@ -45,7 +45,7 @@ public final strictfp class Math
* @return The absolute value.
* @since 2019/04/14
*/
public static int abs(int __v)
public static strictfp int abs(int __v)
{
return (__v < 0 ? -__v : __v);
}
......@@ -57,7 +57,7 @@ public final strictfp class Math
* @return The absolute value.
* @since 2019/04/14
*/
public static long abs(long __v)
public static strictfp long abs(long __v)
{
return (__v < 0 ? -__v : __v);
}
......@@ -69,7 +69,7 @@ public final strictfp class Math
* @return The absolute value.
* @since 2019/04/14
*/
public static float abs(float __v)
public static strictfp float abs(float __v)
{
return Float.intBitsToFloat(0x7FFFFFFF & Float.floatToIntBits(__v));
}
......@@ -81,63 +81,63 @@ public final strictfp class Math
* @return The absolute value.
* @since 2019/04/14
*/
public static double abs(double __v)
public static strictfp double abs(double __v)
{
return Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL &
Double.doubleToLongBits(__v));
}
public static double acos(double __a)
public static strictfp double acos(double __a)
{
throw new todo.TODO();
}
public static double asin(double __a)
public static strictfp double asin(double __a)
{
throw new todo.TODO();
}
public static double atan(double __a)
public static strictfp double atan(double __a)
{
throw new todo.TODO();
}
public static double atan2(double __a, double __b)
public static strictfp double atan2(double __a, double __b)
{
throw new todo.TODO();
}
public static double ceil(double __a)
public static strictfp double ceil(double __a)
{
throw new todo.TODO();
}
public static double copySign(double __a, double __b)
public static strictfp double copySign(double __a, double __b)
{
throw new todo.TODO();
}
public static float copySign(float __a, float __b)
public static strictfp float copySign(float __a, float __b)
{
throw new todo.TODO();
}
public static double cos(double __a)
public static strictfp double cos(double __a)
{
throw new todo.TODO();
}
public static double floor(double __a)
public static strictfp double floor(double __a)
{
throw new todo.TODO();
}
public static int getExponent(float __a)
public static strictfp int getExponent(float __a)
{
throw new todo.TODO();
}
public static int getExponent(double __a)
public static strictfp int getExponent(double __a)
{
throw new todo.TODO();
}
......@@ -153,7 +153,7 @@ public final strictfp class Math
*/
@Deprecated
@ImplementationNote("This method does not exist in the CLDC library.")
public static double log(double __v)
public static strictfp double log(double __v)
{
return FDMLMath.log(__v);
}
......@@ -167,24 +167,24 @@ public final strictfp class Math
* @since 2018/09/29
*/
@SuppressWarnings("ManualMinMaxCalculation")
public static int max(int __a, int __b)
public static strictfp int max(int __a, int __b)
{
if (__a > __b)
return __a;
return __b;
}
public static long max(long __a, long __b)
public static strictfp long max(long __a, long __b)
{
throw new todo.TODO();
}
public static float max(float __a, float __b)
public static strictfp float max(float __a, float __b)
{
throw new todo.TODO();
}
public static double max(double __a, double __b)
public static strictfp double max(double __a, double __b)
{
throw new todo.TODO();
}
......@@ -198,7 +198,7 @@ public final strictfp class Math
* @since 2018/09/29
*/
@SuppressWarnings("ManualMinMaxCalculation")
public static int min(int __a, int __b)
public static strictfp int min(int __a, int __b)
{
if (__a < __b)
return __a;
......@@ -214,7 +214,7 @@ public final strictfp class Math
* @since 2018/12/08
*/
@SuppressWarnings("ManualMinMaxCalculation")
public static long min(long __a, long __b)
public static strictfp long min(long __a, long __b)
{
if (__a < __b)
return __a;
......@@ -230,7 +230,7 @@ public final strictfp class Math
* @since 2018/12/08
*/
@SuppressWarnings("ManualMinMaxCalculation")
public static float min(float __a, float __b)
public static strictfp float min(float __a, float __b)
{
if (__a < __b)
return __a;
......@@ -246,39 +246,39 @@ public final strictfp class Math
* @since 2018/12/08
*/
@SuppressWarnings("ManualMinMaxCalculation")
public static double min(double __a, double __b)
public static strictfp double min(double __a, double __b)
{
if (__a < __b)
return __a;
return __b;
}
public static double random()
public static strictfp double random()
{
throw new todo.TODO();
}
public static int round(float __a)
public static strictfp int round(float __a)
{
throw new todo.TODO();
}
public static long round(double __a)
public static strictfp long round(double __a)
{
throw new todo.TODO();
}
public static double signum(double __a)
public static strictfp double signum(double __a)
{
throw new todo.TODO();
}
public static float signum(float __a)
public static strictfp float signum(float __a)
{
throw new todo.TODO();
}
public static double sin(double __a)
public static strictfp double sin(double __a)
{
throw new todo.TODO();
}
......@@ -290,22 +290,22 @@ public final strictfp class Math
* @return The square root.
* @since 2018/11/03
*/
public static double sqrt(double __v)
public static strictfp double sqrt(double __v)
{
return FDMLMath.sqrt(__v);
}
public static double tan(double __a)
public static strictfp double tan(double __a)
{
throw new todo.TODO();
}
public static double toDegrees(double __a)
public static strictfp double toDegrees(double __a)
{
throw new todo.TODO();
}
public static double toRadians(double __a)
public static strictfp double toRadians(double __a)
{
throw new todo.TODO();
}
......
......@@ -476,12 +476,13 @@ public final class TestResult
// Parse values
long exp = Long.parseLong(__exp.substring(xfc + 1,
(xlc > 0 ? xlc : __exp.length())));
long fudge = Math.abs((xlc > 0 ?
(xlc >= 0 ? xlc : __exp.length())));
long fudge = Math.abs((xlc >= 0 ?
Long.parseLong(__exp.substring(xlc + 1)) : 0));
// Matches as long as we are within the fudge range
return act == exp || (act >= (exp - fudge) && act <= (exp + fudge));
return act == exp ||
(act >= (exp - fudge) && act <= (exp + fudge));
}
// Use normal string comparison
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment