/** * Computes a new DoubleDouble object whose value is <tt>(this - y)</tt>. * * @param y the subtrahend * @return <tt>(this - y)</tt> */ public final DD subtract(double y) { return add(-y); }
/** * Computes a new DoubleDouble object whose value is <tt>(this - y)</tt>. * * @param y the subtrahend * @return <tt>(this - y)</tt> */ public final DD subtract(DD y) { return add(y.negate()); }
/** * Rounds this value to the nearest integer. * The value is rounded to an integer by adding 1/2 and taking the floor of the result. * Special cases: * <ul> * <li>If this value is NaN, returns NaN. * </ul> * * @return this value rounded to the nearest integer */ public DD rint() { if (isNaN()) return this; // may not be 100% correct DD plus5 = this.add(0.5); return plus5.floor(); }
private void checkAddMult2(DD dd) { DD sum = dd.add(dd); DD prod = dd.multiply(new DD(2.0)); checkErrorBound("AddMult2", sum, prod, 0.0); }
DD cy = DD.valueOf(c.y); DD aTerm = (ax.multiply(ax).add(ay.multiply(ay))) .multiply(triAreaDDSlow(bx, by, cx, cy, px, py)); DD bTerm = (bx.multiply(bx).add(by.multiply(by))) .multiply(triAreaDDSlow(ax, ay, cx, cy, px, py)); DD cTerm = (cx.multiply(cx).add(cy.multiply(cy))) .multiply(triAreaDDSlow(ax, ay, bx, by, px, py)); DD pTerm = (px.multiply(px).add(py.multiply(py))) .multiply(triAreaDDSlow(ax, ay, bx, by, cx, cy)); DD sum = aTerm.subtract(bTerm).add(cTerm).subtract(pTerm); boolean isInCircle = sum.doubleValue() > 0;
/** * Uses Taylor series to compute e * * e = 1 + 1 + 1/2! + 1/3! + 1/4! + ... * * @return an approximation to e */ private DD computeEByTaylorSeries() { DD s = DD.valueOf(2.0); DD t = DD.valueOf(1.0); double n = 1.0; int i = 0; while (t.doubleValue() > DD.EPS) { i++; n += 1.0; t = t.divide(DD.valueOf(n)); s = s.add(t); //System.out.println(i + ": " + s); } return s; }
DD cy = new DD(c.y); DD aTerm = (ax.multiply(ax).add(ay.multiply(ay))) .multiply(triAreaDD(bx, by, cx, cy, px, py)); DD bTerm = (bx.multiply(bx).add(by.multiply(by))) .multiply(triAreaDD(ax, ay, cx, cy, px, py)); DD cTerm = (cx.multiply(cx).add(cy.multiply(cy))) .multiply(triAreaDD(ax, ay, bx, by, px, py)); DD pTerm = (px.multiply(px).add(py.multiply(py))) .multiply(triAreaDD(ax, ay, bx, by, cx, cy)); DD sum = aTerm.subtract(bTerm).add(cTerm).subtract(pTerm); boolean isInCircle = sum.doubleValue() > 0;
double d2 = diffSq.hi * (x * 0.5); return axdd.add(d2);
DD aPlusb = add.add(bdd); DD aSubb = add.subtract(bdd); DD abProd = aPlusb.multiply(aSubb);