Skip to content
Snippets Groups Projects
Commit 488c6e3c authored by Miloslav Metelka's avatar Miloslav Metelka
Browse files

Checkstyle fixes.

parent dc412216
No related branches found
No related tags found
No related merge requests found
...@@ -26,14 +26,15 @@ public class Beta { ...@@ -26,14 +26,15 @@ public class Beta {
if (Double.isNaN(a) || Double.isNaN(b)) { if (Double.isNaN(a) || Double.isNaN(b)) {
return a + b; return a + b;
} }
if (a < 0 || b < 0) if (a < 0 || b < 0) {
return RMathError.defaultError(); // ML_ERR_return_NAN return RMathError.defaultError(); // ML_ERR_return_NAN
else if (a == 0 || b == 0) } else if (a == 0 || b == 0) {
return ML_POSINF; return ML_POSINF;
else if (!RRuntime.isFinite(a) || !RRuntime.isFinite(b)) } else if (!RRuntime.isFinite(a) || !RRuntime.isFinite(b)) {
return 0; return 0;
}
if (a + b < xmax) {/* ~= 171.61 for IEEE */ if (a + b < xmax) { /* ~= 171.61 for IEEE */
// return gammafn(a) * gammafn(b) / gammafn(a+b); // return gammafn(a) * gammafn(b) / gammafn(a+b);
/* /*
* All the terms are positive, and all can be large for large or small arguments. They * All the terms are positive, and all can be large for large or small arguments. They
......
...@@ -82,8 +82,9 @@ public final class RMath { ...@@ -82,8 +82,9 @@ public final class RMath {
private static final int MAX_DIGITS = 22; private static final int MAX_DIGITS = 22;
public static double fprec(double x, double digits) { public static double fprec(double x, double digits) {
if (Double.isNaN(x) || Double.isNaN(digits)) if (Double.isNaN(x) || Double.isNaN(digits)) {
return x + digits; return x + digits;
}
if (!RRuntime.isFinite(x)) { if (!RRuntime.isFinite(x)) {
return x; return x;
} }
...@@ -127,25 +128,26 @@ public final class RMath { ...@@ -127,25 +128,26 @@ public final class RMath {
return (sgn * (rint((x / pow10)) * pow10)); return (sgn * (rint((x / pow10)) * pow10));
} }
} else { /* -- LARGE or small -- */ } else { /* -- LARGE or small -- */
boolean do_round = (MAX10E - l10 >= powDi(10., -dig)); boolean doRound = (MAX10E - l10 >= powDi(10., -dig));
int e2 = dig + ((e10 > 0) ? 1 : -1) * MAX_DIGITS; int e2 = dig + ((e10 > 0) ? 1 : -1) * MAX_DIGITS;
double p10 = powDi(10., e2); double p10 = powDi(10., e2);
x *= p10; x *= p10;
double P10 = powDi(10., e10 - e2); double aP10 = powDi(10., e10 - e2);
x *= P10; x *= aP10;
/*-- p10 * P10 = 10 ^ e10 */ /*-- p10 * P10 = 10 ^ e10 */
if (do_round) { if (doRound) {
x += 0.5; x += 0.5;
} }
x = Math.floor(x) / p10; x = Math.floor(x) / p10;
return (sgn * x / P10); return (sgn * x / aP10);
} }
} }
// GNUR from fround.c // GNUR from fround.c
public static double rint(double x) { public static double rint(double x) {
double tmp, sgn = 1.0; double tmp;
double sgn = 1.0;
long ltmp; long ltmp;
if (x != x) { /* NaN */ if (x != x) { /* NaN */
...@@ -160,8 +162,9 @@ public final class RMath { ...@@ -160,8 +162,9 @@ public final class RMath {
if (x < (double) LONG_MAX) { if (x < (double) LONG_MAX) {
ltmp = (long) (x + 0.5); ltmp = (long) (x + 0.5);
/* implement round to even */ /* implement round to even */
if (fabs(x + 0.5 - ltmp) < 10 * DBL_EPSILON && (ltmp % 2 == 1)) if (fabs(x + 0.5 - ltmp) < 10 * DBL_EPSILON && (ltmp % 2 == 1)) {
ltmp--; ltmp--;
}
tmp = ltmp; tmp = ltmp;
} else { } else {
/* ignore round to even: too small a point to bother */ /* ignore round to even: too small a point to bother */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment