00001: //##header
00002: /* Generated from 'DiagBigDecimal.nrx' 27 Mar 2000 22:38:44 [v1.162] */
00003: /* Options: Binary Comments Crossref Format Java Logo Trace1 Verbose3 */
00004: package com.ibm.icu.dev.test.bigdec;
00005:
00006: import java.math.BigInteger;
00007: import com.ibm.icu.dev.test.TestFmwk;
00008: import com.ibm.icu.util.VersionInfo;
00009:
00010: /* ------------------------------------------------------------------ */
00011: /* Decimal diagnostic tests mfc */
00012: /* Copyright (c) IBM Corporation 1996-2005. All Rights Reserved. */
00013: /* ------------------------------------------------------------------ */
00014: /* DiagBigDecimal */
00015: /* */
00016: /* A class that tests the BigDecimal and MathContext classes. */
00017: /* */
00018: /* The tests here are derived from or cover the same paths as: */
00019: /* -- ANSI X3-274 testcases */
00020: /* -- Java JCK testcases */
00021: /* -- NetRexx testcases */
00022: /* -- VM/CMS S/370 REXX implementation testcases [1981+] */
00023: /* -- IBM Vienna Laboratory Rexx compiler testcases [1988+] */
00024: /* -- New testcases */
00025: /* */
00026: /* The authoritative sources for how the underlying technology */
00027: /* (arithmetic) should work are: */
00028: /* -- for digits=0 (fixed point): java.math.BigDecimal */
00029: /* -- for digits>0 (floating point): ANSI X3.274-1996 + errata */
00030: /* */
00031: /* ------------------------------------------------------------------ */
00032: /* Change list */
00033: /* 1997.09.05 Initial implementation, from DiagRexx [NetRexx tests] */
00034: /* 1998.05.02 0.07 changes (e.g., compareTo) */
00035: /* 1998.06.06 Rounding modes and format additions */
00036: /* 1998.06.25 Rename from DiagDecimal; make stand-alone [add */
00037: /* DiagException as a Minor class] */
00038: /* 1998.06.27 Start adding testcases for DIGITS=0/FORM=PLAIN cases */
00039: /* Reorganize for faster trace compilation */
00040: /* 1998.06.28 new: valueof, scale, movePointX, unscaledValue, etc. */
00041: /* 1998.07.07 Scaled divide */
00042: /* 1998.07.08 setScale */
00043: /* 1998.07.15 new scaffolding (Minor Test class) -- see diagabs */
00044: /* 1998.12.14 add toBigDecimal and BigDecimal(java.math.BigDecimal) */
00045: /* 1999.02.04 number preparation rounds instead of digits+1 trunc */
00046: /* 1999.02.09 format method now only has two signatures */
00047: /* 1999.02.27 no longer use Rexx class or RexxIO class */
00048: /* 1999.03.05 add MathContext tests */
00049: /* 1999.03.05 update for 0.96 [no null settings, etc.] */
00050: /* drop sundry constructors; no blanks; char[] gets ints */
00051: /* drop sundry converters, add Exact converters */
00052: /* 1999.05.27 additional tests for scaled arithmetic */
00053: /* 1999.06.29 additional tests for exponent overflows */
00054: /* 1999.07.03 add 'continue' option */
00055: /* 1999.07.10 additional tests for scaled arithmetic */
00056: /* 1999.07.18 randomly-generated tests added for base operators */
00057: /* 1999.10.28 weird intValueExact bad cases */
00058: /* 1999.12.21 multiplication fast path failure and edge cases */
00059: /* 2000.01.01 copyright update */
00060: /* 2000.03.26 cosmetic updates; add extra format() testcases */
00061: /* 2000.03.27 1.00 move to com.ibm.icu.math package; open source release; */
00062: /* change to javadoc comments */
00063: /* ------------------------------------------------------------------ */
00064:
00065: // note BINARY for conversions checking
00066:
00067: /**
00068: * The <code>DiagBigDecimal</code> class forms a standalone test suite
00069: * for the <code>com.ibm.icu.math.BigDecimal</code> and
00070: * <code>com.ibm.icu.math.MathContext</code> classes (or, by changing the
00071: * <code>package</code> statement, other classes of the same names and
00072: * definition in other packages). It may also be used as a constructed
00073: * object to embed the tests in an external test harness.
00074: * <p>
00075: * The tests are collected into <i>groups</i>, each corresponding to a
00076: * tested method or a more general grouping. By default, when run from
00077: * the static {@link #main(java.lang.String[])} method, the run will end
00078: * if any test fails in a group. The <code>continue</code> argument may
00079: * be specified to force the tests to run to completion.
00080: * <p>
00081: * Two minor (inner) classes are used; {@link
00082: * DiagBigDecimal.DiagException} is used to signal the failure of a test
00083: * group, and {@link DiagBigDecimal.Test}, a dependent minor class, is
00084: * used to register tests so that a summary of failures (or success) can be
00085: * presented as each group is completed.
00086: *
00087: * @see com.ibm.icu.math.BigDecimal
00088: * @see com.ibm.icu.math.MathContext
00089: * @version 1.00 2000.03.27
00090: * @author Mike Cowlishaw
00091: */
00092:
00093: public class DiagBigDecimal extends TestFmwk {
00094: private static final java.lang.String $0 = "DiagBigDecimal.nrx";
00095:
00096: /* properties shared */
00097: java.util.Vector Tests = new java.util.Vector(100); // scaffolding
00098:
00099: /* properties private */
00100: private int totalcount = 0; // counts tests run
00101:
00102: /* properties constant private */
00103:
00104: /* Count of test groups */
00105: private static final int testcount = 38;
00106:
00107: private static final com.ibm.icu.math.BigDecimal zero = com.ibm.icu.math.BigDecimal.ZERO;
00108: private static final com.ibm.icu.math.BigDecimal one = com.ibm.icu.math.BigDecimal.ONE;
00109: private static final com.ibm.icu.math.BigDecimal two = new com.ibm.icu.math.BigDecimal(
00110: 2);
00111: private static final com.ibm.icu.math.BigDecimal ten = com.ibm.icu.math.BigDecimal.TEN;
00112: private static final com.ibm.icu.math.BigDecimal tenlong = new com.ibm.icu.math.BigDecimal(
00113: (long) 1234554321); // 10-digiter
00114:
00115: /* Some context objects -- [some of these are checked later] */
00116: private static final com.ibm.icu.math.MathContext mcdef = com.ibm.icu.math.MathContext.DEFAULT;
00117: private static final com.ibm.icu.math.MathContext mc3 = new com.ibm.icu.math.MathContext(
00118: 3);
00119: private static final com.ibm.icu.math.MathContext mc6 = new com.ibm.icu.math.MathContext(
00120: 6);
00121: private static final com.ibm.icu.math.MathContext mc9 = new com.ibm.icu.math.MathContext(
00122: 9);
00123: private static final com.ibm.icu.math.MathContext mc50 = new com.ibm.icu.math.MathContext(
00124: 50);
00125: private static final com.ibm.icu.math.MathContext mcs = new com.ibm.icu.math.MathContext(
00126: 9, com.ibm.icu.math.MathContext.SCIENTIFIC);
00127: private static final com.ibm.icu.math.MathContext mce = new com.ibm.icu.math.MathContext(
00128: 9, com.ibm.icu.math.MathContext.ENGINEERING);
00129: private static final com.ibm.icu.math.MathContext mcld = new com.ibm.icu.math.MathContext(
00130: 9, com.ibm.icu.math.MathContext.SCIENTIFIC, true); // lost digits
00131: private static final com.ibm.icu.math.MathContext mcld0 = new com.ibm.icu.math.MathContext(
00132: 0, com.ibm.icu.math.MathContext.SCIENTIFIC, true); // lost digits, digits=0
00133: private static final com.ibm.icu.math.MathContext mcfd = new com.ibm.icu.math.MathContext(
00134: 0, com.ibm.icu.math.MathContext.PLAIN); // fixed decimal style
00135:
00136: /* boundary primitive values */
00137: private static final byte bmin = -128;
00138: private static final byte bmax = 127;
00139: private static final byte bzer = 0;
00140: private static final byte bneg = -1;
00141: private static final byte bpos = 1;
00142: private static final int imin = -2147483648;
00143: private static final int imax = 2147483647;
00144: private static final int izer = 0;
00145: private static final int ineg = -1;
00146: private static final int ipos = 1;
00147: private static final long lmin = -9223372036854775808L;
00148: private static final long lmax = 9223372036854775807L;
00149: private static final long lzer = (long) 0;
00150: private static final long lneg = (long) -1;
00151: private static final long lpos = (long) 1;
00152: private static final short smin = -32768;
00153: private static final short smax = 32767;
00154: private static final short szer = (short) 0;
00155: private static final short sneg = (short) (-1);
00156: private static final short spos = (short) 1;
00157:
00158: /* properties constant private unused */// present but not referenced
00159: private static final java.lang.String copyright = " Copyright (c) IBM Corporation 1996, 2000. All rights reserved. ";
00160:
00161: /** Constructs a <code>DiagBigDecimal</code> test suite.
00162: * <p>
00163: * Invoke its {@link #diagrun} method to run the tests.
00164: */
00165:
00166: public DiagBigDecimal() {
00167: super ();
00168: }
00169:
00170: static final boolean isJDK15OrLater = VersionInfo.javaVersion()
00171: .compareTo(VersionInfo.getInstance(1, 5)) >= 0;
00172:
00173: /** Run the tests in the test suite.
00174: *
00175: * @param isContinue The <code>boolean</code> which determines whether
00176: * to stop running after a group fails. If 1 (true)
00177: * then the tests should be run to completion if
00178: * possible; if 0 (false) then the run will end if a
00179: * group fails.
00180: * @return an <code>int</code> which is 0 if all tests were
00181: * successful, >0 (the count of failures) if some failures were
00182: * detected, or <0 if an unexpected Exception was signalled.
00183: */
00184:
00185: public int diagrun(boolean isContinue) {
00186: int fails;
00187: int num = 0;
00188: DiagException de = null;
00189: java.lang.RuntimeException e = null;
00190: java.lang.String rest = null;
00191:
00192: fails = 0; // count of failures
00193: try {
00194: num = 1;
00195: num: for (; num <= testcount; num++) { // [testcount is constant set above]
00196: try {
00197: dotest(num);
00198: } catch (DiagException $1) {
00199: de = $1;
00200: say();
00201: errln("**** Failed:" + " " + de.getMessage() + " "
00202: + "****");
00203: say();
00204: fails = fails + de.failcount;
00205: if ((!isContinue))
00206: break num;
00207: }
00208: }
00209: } catch (java.lang.RuntimeException $2) {
00210: e = $2; // any other exception is total failure; just show trace and quit
00211: say();
00212: errln("**** Failed: unexpected exception ****");
00213: e.printStackTrace();
00214: return -1;
00215: }/*num*/
00216:
00217: if (fails == 0)
00218: say("--- All OK ---" + " "
00219: + right("[" + totalcount + " " + "tests]", 15));
00220: else {
00221: if (isContinue) {
00222: if (fails > 1)
00223: rest = "tests";
00224: else
00225: rest = "test";
00226: say("--- All run ---" + " "
00227: + right("[" + totalcount + " " + "tests,", 14)
00228: + " " + "failed" + " " + fails + " " + rest
00229: + "]");
00230:
00231: }
00232: }
00233:
00234: return fails;
00235: }
00236:
00237: /* Run test by number -- method for development/private switching */
00238:
00239: private void dotest(int num) {
00240: {/*select*/
00241: switch (num) {
00242: /* -------------------------------------------------------------- */
00243: /* MathContext */
00244: /* -------------------------------------------------------------- */
00245: case 1:
00246: diagmathcontext();
00247: break;
00248:
00249: /* -------------------------------------------------------------- */
00250: /* Constructors */
00251: /* -------------------------------------------------------------- */
00252: case 2:
00253: diagconstructors();
00254: break;
00255:
00256: /* -------------------------------------------------------------- */
00257: /* Operator methods */
00258: /* -------------------------------------------------------------- */
00259: case 3:
00260: diagabs();
00261: break;
00262: case 4:
00263: diagadd();
00264: break;
00265: case 5:
00266: diagcompareto();
00267: break;
00268: case 6:
00269: diagdivide();
00270: break;
00271: case 7:
00272: diagdivideInteger();
00273: break;
00274: case 8:
00275: diagmax();
00276: break;
00277: case 9:
00278: diagmin();
00279: break;
00280: case 10:
00281: diagmultiply();
00282: break;
00283: case 11:
00284: diagnegate();
00285: break;
00286: case 12:
00287: diagplus();
00288: break;
00289: case 13:
00290: diagpow();
00291: break;
00292: case 14:
00293: diagremainder();
00294: break;
00295: case 15:
00296: diagsubtract();
00297: break;
00298: case 16:
00299: diagmath();
00300: break; // general math
00301:
00302: /* -------------------------------------------------------------- */
00303: /* Other methods */
00304: /* -------------------------------------------------------------- */
00305: case 17:
00306: diagbyteValue();
00307: break;
00308: case 18:
00309: diagcomparetoObj();
00310: break;
00311: case 19:
00312: diagdoublevalue();
00313: break;
00314: case 20:
00315: diagequals();
00316: break;
00317: case 21:
00318: diagfloatvalue();
00319: break;
00320: case 22:
00321: diagformat();
00322: break;
00323: case 23:
00324: diaghashcode();
00325: break;
00326: case 24:
00327: diagintvalue();
00328: break;
00329: case 25:
00330: diaglongvalue();
00331: break;
00332: case 26:
00333: diagmovepointleft();
00334: break;
00335: case 27:
00336: diagmovepointright();
00337: break;
00338: case 28:
00339: diagscale();
00340: break;
00341: case 29:
00342: diagsetscale();
00343: break;
00344: case 30:
00345: diagshortvalue();
00346: break;
00347: case 31:
00348: diagsignum();
00349: break;
00350: case 32:
00351: diagtobigdecimal();
00352: break;
00353: case 33:
00354: diagtobiginteger();
00355: break;
00356: case 34:
00357: diagtochararray();
00358: break;
00359: case 35:
00360: diagtostring();
00361: break;
00362: case 36:
00363: diagunscaledvalue();
00364: break;
00365: case 37:
00366: diagvalueof();
00367: break;
00368:
00369: /* -------------------------------------------------------------- */
00370: /* Mutation test [must be the last test] */
00371: /* -------------------------------------------------------------- */
00372: case 38:
00373: diagmutation();
00374: break;
00375: // if any more, increase testcount above
00376: default: {
00377: say("*** dotest case not found:" + " " + num + " "
00378: + "***");
00379: }
00380: }
00381: }
00382: return;
00383: }
00384:
00385: /*--------------------------------------------------------------------*/
00386: /* Diagnostic group methods */
00387: /*--------------------------------------------------------------------*/
00388:
00389: /** Test constructors (and {@link #toString()} for equalities). */
00390:
00391: public void diagconstructors() {
00392: boolean flag = false;
00393: java.lang.String num;
00394: java.math.BigInteger bip;
00395: java.math.BigInteger biz;
00396: java.math.BigInteger bin;
00397: com.ibm.icu.math.BigDecimal bda;
00398: com.ibm.icu.math.BigDecimal bdb;
00399: com.ibm.icu.math.BigDecimal bmc;
00400: com.ibm.icu.math.BigDecimal bmd;
00401: com.ibm.icu.math.BigDecimal bme;
00402: java.lang.RuntimeException e = null;
00403: char ca[];
00404: double dzer;
00405: double dpos;
00406: double dneg;
00407: double dpos5;
00408: double dneg5;
00409: double dmin;
00410: double dmax;
00411: double d;
00412: java.lang.String badstrings[];
00413: int i = 0;
00414:
00415: // constants [statically-called constructors]
00416: (new Test("con001")).ok = (com.ibm.icu.math.BigDecimal.ZERO
00417: .toString()).equals("0");
00418: (new Test("con002")).ok = (com.ibm.icu.math.BigDecimal.ONE
00419: .toString()).equals("1");
00420: (new Test("con003")).ok = (com.ibm.icu.math.BigDecimal.TEN
00421: .toString()).equals("10");
00422: (new Test("con004")).ok = (com.ibm.icu.math.BigDecimal.ZERO
00423: .intValueExact()) == 0;
00424: (new Test("con005")).ok = (com.ibm.icu.math.BigDecimal.ONE
00425: .intValueExact()) == 1;
00426: (new Test("con006")).ok = (com.ibm.icu.math.BigDecimal.TEN
00427: .intValueExact()) == 10;
00428:
00429: // [java.math.] BigDecimal
00430: //#ifndef FOUNDATION
00431: (new Test("cbd001")).ok = ((new com.ibm.icu.math.BigDecimal(
00432: new java.math.BigDecimal("0"))).toString()).equals("0");
00433: (new Test("cbd002")).ok = ((new com.ibm.icu.math.BigDecimal(
00434: new java.math.BigDecimal("1"))).toString()).equals("1");
00435: (new Test("cbd003")).ok = ((new com.ibm.icu.math.BigDecimal(
00436: new java.math.BigDecimal("10"))).toString())
00437: .equals("10");
00438: (new Test("cbd004")).ok = ((new com.ibm.icu.math.BigDecimal(
00439: new java.math.BigDecimal("1000"))).toString())
00440: .equals("1000");
00441: (new Test("cbd005")).ok = ((new com.ibm.icu.math.BigDecimal(
00442: new java.math.BigDecimal("10.0"))).toString())
00443: .equals("10.0");
00444: (new Test("cbd006")).ok = ((new com.ibm.icu.math.BigDecimal(
00445: new java.math.BigDecimal("10.1"))).toString())
00446: .equals("10.1");
00447: (new Test("cbd007")).ok = ((new com.ibm.icu.math.BigDecimal(
00448: new java.math.BigDecimal("-1.1"))).toString())
00449: .equals("-1.1");
00450: (new Test("cbd008")).ok = ((new com.ibm.icu.math.BigDecimal(
00451: new java.math.BigDecimal("-9.0"))).toString())
00452: .equals("-9.0");
00453: (new Test("cbd009")).ok = ((new com.ibm.icu.math.BigDecimal(
00454: new java.math.BigDecimal("0.9"))).toString())
00455: .equals("0.9");
00456:
00457: num = "123456789.123456789";
00458: (new Test("cbd010")).ok = ((new com.ibm.icu.math.BigDecimal(
00459: new java.math.BigDecimal(num))).toString()).equals(num);
00460: num = "123456789.000000000";
00461: (new Test("cbd011")).ok = ((new com.ibm.icu.math.BigDecimal(
00462: new java.math.BigDecimal(num))).toString()).equals(num);
00463: num = "123456789000000000";
00464: (new Test("cbd012")).ok = ((new com.ibm.icu.math.BigDecimal(
00465: new java.math.BigDecimal(num))).toString()).equals(num);
00466: num = "0.00000123456789";
00467: (new Test("cbd013")).ok = ((new com.ibm.icu.math.BigDecimal(
00468: new java.math.BigDecimal(num))).toString()).equals(num);
00469: num = "0.000000123456789";
00470:
00471: // ignore format change issues with 1.5
00472: if (!isJDK15OrLater)
00473: (new Test("cbd014")).ok = ((new com.ibm.icu.math.BigDecimal(
00474: new java.math.BigDecimal(num))).toString())
00475: .equals(num);
00476:
00477: try {
00478: checknull: do {
00479: new com.ibm.icu.math.BigDecimal(
00480: (java.math.BigDecimal) null);
00481: flag = false;
00482: } while (false);
00483: } catch (java.lang.NullPointerException $3) {
00484: flag = true;
00485: }/*checknull*/
00486: (new Test("cbi015")).ok = flag;
00487: //#endif
00488:
00489: // BigInteger
00490: bip = new BigInteger("987654321987654321987654321"); // biggie +ve
00491: biz = new BigInteger("0"); // biggie 0
00492: bin = new BigInteger("-12345678998765432112345678"); // biggie -ve
00493: (new Test("cbi001")).ok = ((new com.ibm.icu.math.BigDecimal(bip))
00494: .toString()).equals(bip.toString());
00495: (new Test("cbi002")).ok = ((new com.ibm.icu.math.BigDecimal(biz))
00496: .toString()).equals("0");
00497: (new Test("cbi003")).ok = ((new com.ibm.icu.math.BigDecimal(bin))
00498: .toString()).equals(bin.toString());
00499: try {
00500: checknull: do {
00501: new com.ibm.icu.math.BigDecimal(
00502: (java.math.BigInteger) null);
00503: flag = false;
00504: } while (false);
00505: } catch (java.lang.NullPointerException $4) {
00506: flag = true;
00507: }/*checknull*/
00508: (new Test("cbi004")).ok = flag;
00509:
00510: // BigInteger with scale
00511: bip = new BigInteger("123456789"); // bigish
00512: bda = new com.ibm.icu.math.BigDecimal(bip);
00513: bdb = new com.ibm.icu.math.BigDecimal(bip, 5);
00514: bmc = new com.ibm.icu.math.BigDecimal(bip, 15);
00515: (new Test("cbs001")).ok = (bda.toString()).equals("123456789");
00516: (new Test("cbs002")).ok = (bdb.toString()).equals("1234.56789");
00517: (new Test("cbs003")).ok = (bmc.toString())
00518: .equals("0.000000123456789");
00519: bip = new BigInteger("123456789123456789123456789"); // biggie
00520: bda = new com.ibm.icu.math.BigDecimal(bip);
00521: bdb = new com.ibm.icu.math.BigDecimal(bip, 7);
00522: bmc = new com.ibm.icu.math.BigDecimal(bip, 13);
00523: bmd = new com.ibm.icu.math.BigDecimal(bip, 19);
00524: bme = new com.ibm.icu.math.BigDecimal(bip, 29);
00525: (new Test("cbs011")).ok = (bda.toString())
00526: .equals("123456789123456789123456789");
00527: (new Test("cbs012")).ok = (bdb.toString())
00528: .equals("12345678912345678912.3456789");
00529: (new Test("cbs013")).ok = (bmc.toString())
00530: .equals("12345678912345.6789123456789");
00531: (new Test("cbs014")).ok = (bmd.toString())
00532: .equals("12345678.9123456789123456789");
00533: (new Test("cbs015")).ok = (bme.toString())
00534: .equals("0.00123456789123456789123456789");
00535: try {
00536: checknull: do {
00537: new com.ibm.icu.math.BigDecimal(
00538: (java.math.BigInteger) null, 1);
00539: flag = false;
00540: } while (false);
00541: } catch (java.lang.NullPointerException $5) {
00542: flag = true;
00543: }/*checknull*/
00544: (new Test("cbs004")).ok = flag;
00545: try {
00546: checkscale: do {
00547: new com.ibm.icu.math.BigDecimal(bip, -8);
00548: flag = false;
00549: } while (false);
00550: } catch (java.lang.RuntimeException $6) {
00551: e = $6;
00552: flag = (e.getMessage()).equals("Negative scale: -8");
00553: }/*checkscale*/
00554: (new Test("cbs005")).ok = flag;
00555:
00556: // char[]
00557: // We just test it's there
00558: // Functionality is tested by BigDecimal(String).
00559: ca = ("123.45").toCharArray();
00560: (new Test("cca001")).ok = ((new com.ibm.icu.math.BigDecimal(ca))
00561: .toString()).equals("123.45");
00562: try {
00563: checknull: do {
00564: new com.ibm.icu.math.BigDecimal((char[]) null);
00565: flag = false;
00566: } while (false);
00567: } catch (java.lang.NullPointerException $7) {
00568: flag = true;
00569: }/*checknull*/
00570: (new Test("cca010")).ok = flag;
00571:
00572: // char[],int,int
00573: // We just test it's there, and that offsets work.
00574: // Functionality is tested by BigDecimal(String).
00575: ca = ("123.45").toCharArray();
00576: (new Test("cca101")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00577: 0, 6)).toString()).equals("123.45");
00578: (new Test("cca102")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00579: 1, 5)).toString()).equals("23.45");
00580: (new Test("cca103")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00581: 2, 4)).toString()).equals("3.45");
00582: (new Test("cca104")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00583: 3, 3)).toString()).equals("0.45");
00584: (new Test("cca105")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00585: 4, 2)).toString()).equals("45");
00586: (new Test("cca106")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00587: 5, 1)).toString()).equals("5");
00588:
00589: (new Test("cca110")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00590: 0, 1)).toString()).equals("1");
00591: (new Test("cca111")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00592: 1, 1)).toString()).equals("2");
00593: (new Test("cca112")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00594: 2, 1)).toString()).equals("3");
00595: (new Test("cca113")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00596: 4, 1)).toString()).equals("4");
00597:
00598: (new Test("cca120")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00599: 0, 2)).toString()).equals("12");
00600: (new Test("cca121")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00601: 1, 2)).toString()).equals("23");
00602: (new Test("cca122")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00603: 2, 2)).toString()).equals("3");
00604: (new Test("cca123")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00605: 3, 2)).toString()).equals("0.4");
00606:
00607: (new Test("cca130")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00608: 0, 3)).toString()).equals("123");
00609: (new Test("cca131")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00610: 1, 3)).toString()).equals("23");
00611: (new Test("cca132")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00612: 2, 3)).toString()).equals("3.4");
00613:
00614: (new Test("cca140")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00615: 0, 4)).toString()).equals("123");
00616: (new Test("cca141")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00617: 1, 4)).toString()).equals("23.4");
00618:
00619: (new Test("cca150")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00620: 0, 5)).toString()).equals("123.4");
00621:
00622: // a couple of oddies
00623: ca = ("x23.4x").toCharArray();
00624: (new Test("cca160")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00625: 1, 4)).toString()).equals("23.4");
00626: (new Test("cca161")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00627: 1, 1)).toString()).equals("2");
00628: (new Test("cca162")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00629: 4, 1)).toString()).equals("4");
00630:
00631: ca = ("0123456789.9876543210").toCharArray();
00632: (new Test("cca163")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00633: 0, 21)).toString()).equals("123456789.9876543210");
00634: (new Test("cca164")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00635: 1, 20)).toString()).equals("123456789.9876543210");
00636: (new Test("cca165")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00637: 2, 19)).toString()).equals("23456789.9876543210");
00638: (new Test("cca166")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00639: 2, 18)).toString()).equals("23456789.987654321");
00640: (new Test("cca167")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00641: 2, 17)).toString()).equals("23456789.98765432");
00642: (new Test("cca168")).ok = ((new com.ibm.icu.math.BigDecimal(ca,
00643: 2, 16)).toString()).equals("23456789.9876543");
00644:
00645: try {
00646: checknull: do {
00647: new com.ibm.icu.math.BigDecimal((char[]) null, 0, 1);
00648: flag = false;
00649: } while (false);
00650: } catch (java.lang.NullPointerException $8) {
00651: flag = true;
00652: }/*checknull*/
00653: (new Test("cca200")).ok = flag;
00654:
00655: try {
00656: checklen: do {
00657: new com.ibm.icu.math.BigDecimal("123".toCharArray(), 0,
00658: 0);
00659: flag = false;
00660: } while (false);
00661: } catch (java.lang.NumberFormatException $9) {
00662: flag = true;
00663: }/*checklen*/
00664: (new Test("cca201")).ok = flag;
00665:
00666: try {
00667: checkbound: do {
00668: new com.ibm.icu.math.BigDecimal("123".toCharArray(), 2,
00669: 4);
00670: flag = false;
00671: } while (false);
00672: } catch (java.lang.RuntimeException $10) { // anything OK
00673: flag = true;
00674: }/*checkbound*/
00675: (new Test("cca202")).ok = flag;
00676: try {
00677: checkbound2: do {
00678: new com.ibm.icu.math.BigDecimal("123".toCharArray(),
00679: -1, 2);
00680: flag = false;
00681: } while (false);
00682: } catch (java.lang.RuntimeException $11) { // anything OK
00683: flag = true;
00684: }/*checkbound2*/
00685: (new Test("cca203")).ok = flag;
00686: try {
00687: checkbound3: do {
00688: new com.ibm.icu.math.BigDecimal("123".toCharArray(), 1,
00689: -2);
00690: flag = false;
00691: } while (false);
00692: } catch (java.lang.RuntimeException $12) { // anything OK
00693: flag = true;
00694: }/*checkbound3*/
00695: (new Test("cca204")).ok = flag;
00696:
00697: //#ifndef FOUNDATION
00698: // double [deprecated]
00699: // Note that many of these differ from the valueOf(double) results.
00700: dzer = (double) 0;
00701: dpos = (double) 1;
00702: dpos = dpos / ((double) 10);
00703: dneg = (double) -dpos;
00704: (new Test("cdo001")).ok = ((new com.ibm.icu.math.BigDecimal(
00705: dneg)).toString())
00706: .equals("-0.1000000000000000055511151231257827021181583404541015625");
00707:
00708: (new Test("cdo002")).ok = ((new com.ibm.icu.math.BigDecimal(
00709: dzer)).toString()).equals("0"); // NB, not '0.0'
00710: (new Test("cdo003")).ok = ((new com.ibm.icu.math.BigDecimal(
00711: dpos)).toString())
00712: .equals("0.1000000000000000055511151231257827021181583404541015625");
00713:
00714: dpos5 = (double) 0.5D;
00715: dneg5 = (double) -dpos5;
00716: (new Test("cdo004")).ok = ((new com.ibm.icu.math.BigDecimal(
00717: dneg5)).toString()).equals("-0.5");
00718: (new Test("cdo005")).ok = ((new com.ibm.icu.math.BigDecimal(
00719: dpos5)).toString()).equals("0.5");
00720: dmin = java.lang.Double.MIN_VALUE;
00721: dmax = java.lang.Double.MAX_VALUE;
00722: if (!isJDK15OrLater) // for some reason we format using scientific notation on 1.5 after 30 decimals or so
00723: (new Test("cdo006")).ok = ((new com.ibm.icu.math.BigDecimal(
00724: dmin)).toString())
00725: .equals("0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004940656458412465441765687928682213723650598026143247644255856825006755072702087518652998363616359923797965646954457177309266567103559397963987747960107818781263007131903114045278458171678489821036887186360569987307230500063874091535649843873124733972731696151400317153853980741262385655911710266585566867681870395603106249319452715914924553293054565444011274801297099995419319894090804165633245247571478690147267801593552386115501348035264934720193790268107107491703332226844753335720832431936092382893458368060106011506169809753078342277318329247904982524730776375927247874656084778203734469699533647017972677717585125660551199131504891101451037862738167250955837389733598993664809941164205702637090279242767544565229087538682506419718265533447265625");
00726:
00727: (new Test("cdo007")).ok = ((new com.ibm.icu.math.BigDecimal(
00728: dmax)).toString())
00729: .equals("179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368");
00730:
00731: // nasties
00732: d = (double) 9;
00733: d = d / ((double) 10);
00734: (new Test("cdo010")).ok = ((new com.ibm.icu.math.BigDecimal(d))
00735: .toString())
00736: .equals("0.90000000000000002220446049250313080847263336181640625");
00737:
00738: d = d / ((double) 10);
00739: (new Test("cdo011")).ok = ((new com.ibm.icu.math.BigDecimal(d))
00740: .toString())
00741: .equals("0.0899999999999999966693309261245303787291049957275390625");
00742:
00743: d = d / ((double) 10);
00744: (new Test("cdo012")).ok = ((new com.ibm.icu.math.BigDecimal(d))
00745: .toString())
00746: .equals("0.00899999999999999931998839741709161899052560329437255859375");
00747:
00748: d = d / ((double) 10);
00749: (new Test("cdo013")).ok = ((new com.ibm.icu.math.BigDecimal(d))
00750: .toString())
00751: .equals("0.00089999999999999997536692664112933925935067236423492431640625");
00752:
00753: d = d / ((double) 10);
00754: (new Test("cdo014")).ok = ((new com.ibm.icu.math.BigDecimal(d))
00755: .toString())
00756: .equals("0.00008999999999999999211568180168541175589780323207378387451171875");
00757:
00758: d = d / ((double) 10);
00759: (new Test("cdo015")).ok = ((new com.ibm.icu.math.BigDecimal(d))
00760: .toString())
00761: .equals("0.00000899999999999999853394182236510090433512232266366481781005859375");
00762:
00763: d = d / ((double) 10);
00764: if (!isJDK15OrLater)
00765: (new Test("cdo016")).ok = ((new com.ibm.icu.math.BigDecimal(
00766: d)).toString())
00767: .equals("0.000000899999999999999853394182236510090433512232266366481781005859375");
00768:
00769: d = d / ((double) 10);
00770: if (!isJDK15OrLater)
00771: (new Test("cdo017")).ok = ((new com.ibm.icu.math.BigDecimal(
00772: d)).toString())
00773: .equals("0.0000000899999999999999853394182236510090433512232266366481781005859375");
00774:
00775: d = d / ((double) 10);
00776: if (!isJDK15OrLater)
00777: (new Test("cdo018")).ok = ((new com.ibm.icu.math.BigDecimal(
00778: d)).toString())
00779: .equals("0.000000008999999999999997872197332322678764437995369007694534957408905029296875");
00780: //#endif
00781:
00782: try {
00783: checkpin: do {
00784: new com.ibm.icu.math.BigDecimal(
00785: java.lang.Double.POSITIVE_INFINITY);
00786: flag = false;
00787: } while (false);
00788: } catch (java.lang.NumberFormatException $13) {
00789: flag = true;
00790: }/*checkpin*/
00791: (new Test("cdo101")).ok = flag;
00792: try {
00793: checknin: do {
00794: new com.ibm.icu.math.BigDecimal(
00795: java.lang.Double.NEGATIVE_INFINITY);
00796: flag = false;
00797: } while (false);
00798: } catch (java.lang.NumberFormatException $14) {
00799: flag = true;
00800: }/*checknin*/
00801: (new Test("cdo102")).ok = flag;
00802: try {
00803: checknan: do {
00804: new com.ibm.icu.math.BigDecimal(java.lang.Double.NaN);
00805: flag = false;
00806: } while (false);
00807: } catch (java.lang.NumberFormatException $15) {
00808: flag = true;
00809: }/*checknan*/
00810: (new Test("cdo103")).ok = flag;
00811:
00812: // int
00813: (new Test("cin001")).ok = ((new com.ibm.icu.math.BigDecimal(
00814: imin)).toString()).equals("-2147483648");
00815: (new Test("cin002")).ok = ((new com.ibm.icu.math.BigDecimal(
00816: imax)).toString()).equals("2147483647");
00817: (new Test("cin003")).ok = ((new com.ibm.icu.math.BigDecimal(
00818: ineg)).toString()).equals("-1");
00819: (new Test("cin004")).ok = ((new com.ibm.icu.math.BigDecimal(
00820: izer)).toString()).equals("0");
00821: (new Test("cin005")).ok = ((new com.ibm.icu.math.BigDecimal(
00822: ipos)).toString()).equals("1");
00823: (new Test("cin006")).ok = ((new com.ibm.icu.math.BigDecimal(10))
00824: .toString()).equals("10");
00825: (new Test("cin007")).ok = ((new com.ibm.icu.math.BigDecimal(9))
00826: .toString()).equals("9");
00827: (new Test("cin008")).ok = ((new com.ibm.icu.math.BigDecimal(5))
00828: .toString()).equals("5");
00829: (new Test("cin009")).ok = ((new com.ibm.icu.math.BigDecimal(2))
00830: .toString()).equals("2");
00831: (new Test("cin010")).ok = ((new com.ibm.icu.math.BigDecimal(-2))
00832: .toString()).equals("-2");
00833: (new Test("cin011")).ok = ((new com.ibm.icu.math.BigDecimal(-5))
00834: .toString()).equals("-5");
00835: (new Test("cin012")).ok = ((new com.ibm.icu.math.BigDecimal(-9))
00836: .toString()).equals("-9");
00837: (new Test("cin013")).ok = ((new com.ibm.icu.math.BigDecimal(-10))
00838: .toString()).equals("-10");
00839: (new Test("cin014")).ok = ((new com.ibm.icu.math.BigDecimal(-11))
00840: .toString()).equals("-11");
00841: (new Test("cin015")).ok = ((new com.ibm.icu.math.BigDecimal(-99))
00842: .toString()).equals("-99");
00843: (new Test("cin016")).ok = ((new com.ibm.icu.math.BigDecimal(
00844: -100)).toString()).equals("-100");
00845: (new Test("cin017")).ok = ((new com.ibm.icu.math.BigDecimal(
00846: -999)).toString()).equals("-999");
00847: (new Test("cin018")).ok = ((new com.ibm.icu.math.BigDecimal(
00848: -1000)).toString()).equals("-1000");
00849:
00850: (new Test("cin019")).ok = ((new com.ibm.icu.math.BigDecimal(11))
00851: .toString()).equals("11");
00852: (new Test("cin020")).ok = ((new com.ibm.icu.math.BigDecimal(99))
00853: .toString()).equals("99");
00854: (new Test("cin021")).ok = ((new com.ibm.icu.math.BigDecimal(100))
00855: .toString()).equals("100");
00856: (new Test("cin022")).ok = ((new com.ibm.icu.math.BigDecimal(999))
00857: .toString()).equals("999");
00858: (new Test("cin023")).ok = ((new com.ibm.icu.math.BigDecimal(
00859: 1000)).toString()).equals("1000");
00860:
00861: // long
00862: (new Test("clo001")).ok = ((new com.ibm.icu.math.BigDecimal(
00863: lmin)).toString()).equals("-9223372036854775808");
00864: (new Test("clo002")).ok = ((new com.ibm.icu.math.BigDecimal(
00865: lmax)).toString()).equals("9223372036854775807");
00866: (new Test("clo003")).ok = ((new com.ibm.icu.math.BigDecimal(
00867: lneg)).toString()).equals("-1");
00868: (new Test("clo004")).ok = ((new com.ibm.icu.math.BigDecimal(
00869: lzer)).toString()).equals("0");
00870: (new Test("clo005")).ok = ((new com.ibm.icu.math.BigDecimal(
00871: lpos)).toString()).equals("1");
00872:
00873: // String [many more examples are elsewhere]
00874: // strings without E cannot generate E in result
00875: (new Test("cst001")).ok = ((new com.ibm.icu.math.BigDecimal(
00876: "12")).toString()).equals("12");
00877: (new Test("cst002")).ok = ((new com.ibm.icu.math.BigDecimal(
00878: "-76")).toString()).equals("-76");
00879: (new Test("cst003")).ok = ((new com.ibm.icu.math.BigDecimal(
00880: "12.76")).toString()).equals("12.76");
00881: (new Test("cst004")).ok = ((new com.ibm.icu.math.BigDecimal(
00882: "+12.76")).toString()).equals("12.76");
00883: (new Test("cst005")).ok = ((new com.ibm.icu.math.BigDecimal(
00884: "012.76")).toString()).equals("12.76");
00885: (new Test("cst006")).ok = ((new com.ibm.icu.math.BigDecimal(
00886: "+0.003")).toString()).equals("0.003");
00887: (new Test("cst007")).ok = ((new com.ibm.icu.math.BigDecimal(
00888: "17.")).toString()).equals("17");
00889: (new Test("cst008")).ok = ((new com.ibm.icu.math.BigDecimal(
00890: ".5")).toString()).equals("0.5");
00891: (new Test("cst009")).ok = ((new com.ibm.icu.math.BigDecimal(
00892: "044")).toString()).equals("44");
00893: (new Test("cst010")).ok = ((new com.ibm.icu.math.BigDecimal(
00894: "0044")).toString()).equals("44");
00895: (new Test("cst011")).ok = ((new com.ibm.icu.math.BigDecimal(
00896: "0.0005")).toString()).equals("0.0005");
00897: (new Test("cst012")).ok = ((new com.ibm.icu.math.BigDecimal(
00898: "00.00005")).toString()).equals("0.00005");
00899: (new Test("cst013")).ok = ((new com.ibm.icu.math.BigDecimal(
00900: "0.000005")).toString()).equals("0.000005");
00901: (new Test("cst014")).ok = ((new com.ibm.icu.math.BigDecimal(
00902: "0.0000005")).toString()).equals("0.0000005"); // \NR
00903: (new Test("cst015")).ok = ((new com.ibm.icu.math.BigDecimal(
00904: "0.00000005")).toString()).equals("0.00000005"); // \NR
00905: (new Test("cst016")).ok = ((new com.ibm.icu.math.BigDecimal(
00906: "12345678.876543210")).toString())
00907: .equals("12345678.876543210");
00908: (new Test("cst017")).ok = ((new com.ibm.icu.math.BigDecimal(
00909: "2345678.876543210")).toString())
00910: .equals("2345678.876543210");
00911: (new Test("cst018")).ok = ((new com.ibm.icu.math.BigDecimal(
00912: "345678.876543210")).toString())
00913: .equals("345678.876543210");
00914: (new Test("cst019")).ok = ((new com.ibm.icu.math.BigDecimal(
00915: "0345678.87654321")).toString())
00916: .equals("345678.87654321");
00917: (new Test("cst020")).ok = ((new com.ibm.icu.math.BigDecimal(
00918: "345678.8765432")).toString()).equals("345678.8765432");
00919: (new Test("cst021")).ok = ((new com.ibm.icu.math.BigDecimal(
00920: "+345678.8765432")).toString())
00921: .equals("345678.8765432");
00922: (new Test("cst022")).ok = ((new com.ibm.icu.math.BigDecimal(
00923: "+0345678.8765432")).toString())
00924: .equals("345678.8765432");
00925: (new Test("cst023")).ok = ((new com.ibm.icu.math.BigDecimal(
00926: "+00345678.8765432")).toString())
00927: .equals("345678.8765432");
00928: (new Test("cst024")).ok = ((new com.ibm.icu.math.BigDecimal(
00929: "-345678.8765432")).toString())
00930: .equals("-345678.8765432");
00931: (new Test("cst025")).ok = ((new com.ibm.icu.math.BigDecimal(
00932: "-0345678.8765432")).toString())
00933: .equals("-345678.8765432");
00934: (new Test("cst026")).ok = ((new com.ibm.icu.math.BigDecimal(
00935: "-00345678.8765432")).toString())
00936: .equals("-345678.8765432");
00937:
00938: // exotics --
00939: (new Test("cst035")).ok = ((new com.ibm.icu.math.BigDecimal(
00940: "\u0e57.\u0e50")).toString()).equals("7.0");
00941: (new Test("cst036")).ok = ((new com.ibm.icu.math.BigDecimal(
00942: "\u0b66.\u0b67")).toString()).equals("0.1");
00943: (new Test("cst037")).ok = ((new com.ibm.icu.math.BigDecimal(
00944: "\u0b66\u0b66")).toString()).equals("0");
00945: (new Test("cst038")).ok = ((new com.ibm.icu.math.BigDecimal(
00946: "\u0b6a\u0b66")).toString()).equals("40");
00947:
00948: // strings with E
00949: (new Test("cst040")).ok = ((new com.ibm.icu.math.BigDecimal(
00950: "1E+9")).toString()).equals("1E+9");
00951: (new Test("cst041")).ok = ((new com.ibm.icu.math.BigDecimal(
00952: "1e+09")).toString()).equals("1E+9");
00953: (new Test("cst042")).ok = ((new com.ibm.icu.math.BigDecimal(
00954: "1E+90")).toString()).equals("1E+90");
00955: (new Test("cst043")).ok = ((new com.ibm.icu.math.BigDecimal(
00956: "+1E+009")).toString()).equals("1E+9");
00957: (new Test("cst044")).ok = ((new com.ibm.icu.math.BigDecimal(
00958: "0E+9")).toString()).equals("0");
00959: (new Test("cst045")).ok = ((new com.ibm.icu.math.BigDecimal(
00960: "1E+9")).toString()).equals("1E+9");
00961: (new Test("cst046")).ok = ((new com.ibm.icu.math.BigDecimal(
00962: "1E+09")).toString()).equals("1E+9");
00963: (new Test("cst047")).ok = ((new com.ibm.icu.math.BigDecimal(
00964: "1e+90")).toString()).equals("1E+90");
00965: (new Test("cst048")).ok = ((new com.ibm.icu.math.BigDecimal(
00966: "1E+009")).toString()).equals("1E+9");
00967: (new Test("cst049")).ok = ((new com.ibm.icu.math.BigDecimal(
00968: "0E+9")).toString()).equals("0");
00969: (new Test("cst050")).ok = ((new com.ibm.icu.math.BigDecimal(
00970: "1E9")).toString()).equals("1E+9");
00971: (new Test("cst051")).ok = ((new com.ibm.icu.math.BigDecimal(
00972: "1e09")).toString()).equals("1E+9");
00973: (new Test("cst052")).ok = ((new com.ibm.icu.math.BigDecimal(
00974: "1E90")).toString()).equals("1E+90");
00975: (new Test("cst053")).ok = ((new com.ibm.icu.math.BigDecimal(
00976: "1E009")).toString()).equals("1E+9");
00977: (new Test("cst054")).ok = ((new com.ibm.icu.math.BigDecimal(
00978: "0E9")).toString()).equals("0");
00979: (new Test("cst055")).ok = ((new com.ibm.icu.math.BigDecimal(
00980: "0.000e+0")).toString()).equals("0");
00981: (new Test("cst056")).ok = ((new com.ibm.icu.math.BigDecimal(
00982: "0.000E-1")).toString()).equals("0");
00983: (new Test("cst057")).ok = ((new com.ibm.icu.math.BigDecimal(
00984: "4E+9")).toString()).equals("4E+9");
00985: (new Test("cst058")).ok = ((new com.ibm.icu.math.BigDecimal(
00986: "44E+9")).toString()).equals("4.4E+10");
00987: (new Test("cst059")).ok = ((new com.ibm.icu.math.BigDecimal(
00988: "0.73e-7")).toString()).equals("7.3E-8");
00989: (new Test("cst060")).ok = ((new com.ibm.icu.math.BigDecimal(
00990: "00E+9")).toString()).equals("0");
00991: (new Test("cst061")).ok = ((new com.ibm.icu.math.BigDecimal(
00992: "00E-9")).toString()).equals("0");
00993: (new Test("cst062")).ok = ((new com.ibm.icu.math.BigDecimal(
00994: "10E+9")).toString()).equals("1.0E+10");
00995: (new Test("cst063")).ok = ((new com.ibm.icu.math.BigDecimal(
00996: "10E+09")).toString()).equals("1.0E+10");
00997: (new Test("cst064")).ok = ((new com.ibm.icu.math.BigDecimal(
00998: "10e+90")).toString()).equals("1.0E+91");
00999: (new Test("cst065")).ok = ((new com.ibm.icu.math.BigDecimal(
01000: "10E+009")).toString()).equals("1.0E+10");
01001: (new Test("cst066")).ok = ((new com.ibm.icu.math.BigDecimal(
01002: "100e+9")).toString()).equals("1.00E+11");
01003: (new Test("cst067")).ok = ((new com.ibm.icu.math.BigDecimal(
01004: "100e+09")).toString()).equals("1.00E+11");
01005: (new Test("cst068")).ok = ((new com.ibm.icu.math.BigDecimal(
01006: "100E+90")).toString()).equals("1.00E+92");
01007: (new Test("cst069")).ok = ((new com.ibm.icu.math.BigDecimal(
01008: "100e+009")).toString()).equals("1.00E+11");
01009:
01010: (new Test("cst070")).ok = ((new com.ibm.icu.math.BigDecimal(
01011: "1.265")).toString()).equals("1.265");
01012: (new Test("cst071")).ok = ((new com.ibm.icu.math.BigDecimal(
01013: "1.265E-20")).toString()).equals("1.265E-20");
01014: (new Test("cst072")).ok = ((new com.ibm.icu.math.BigDecimal(
01015: "1.265E-8")).toString()).equals("1.265E-8");
01016: (new Test("cst073")).ok = ((new com.ibm.icu.math.BigDecimal(
01017: "1.265E-4")).toString()).equals("1.265E-4");
01018: (new Test("cst074")).ok = ((new com.ibm.icu.math.BigDecimal(
01019: "1.265E-3")).toString()).equals("1.265E-3");
01020: (new Test("cst075")).ok = ((new com.ibm.icu.math.BigDecimal(
01021: "1.265E-2")).toString()).equals("1.265E-2");
01022: (new Test("cst076")).ok = ((new com.ibm.icu.math.BigDecimal(
01023: "1.265E-1")).toString()).equals("1.265E-1");
01024: (new Test("cst077")).ok = ((new com.ibm.icu.math.BigDecimal(
01025: "1.265E-0")).toString()).equals("1.265");
01026: (new Test("cst078")).ok = ((new com.ibm.icu.math.BigDecimal(
01027: "1.265E+1")).toString()).equals("1.265E+1");
01028: (new Test("cst079")).ok = ((new com.ibm.icu.math.BigDecimal(
01029: "1.265E+2")).toString()).equals("1.265E+2");
01030: (new Test("cst080")).ok = ((new com.ibm.icu.math.BigDecimal(
01031: "1.265E+3")).toString()).equals("1.265E+3");
01032: (new Test("cst081")).ok = ((new com.ibm.icu.math.BigDecimal(
01033: "1.265E+4")).toString()).equals("1.265E+4");
01034: (new Test("cst082")).ok = ((new com.ibm.icu.math.BigDecimal(
01035: "1.265E+8")).toString()).equals("1.265E+8");
01036: (new Test("cst083")).ok = ((new com.ibm.icu.math.BigDecimal(
01037: "1.265E+20")).toString()).equals("1.265E+20");
01038:
01039: (new Test("cst090")).ok = ((new com.ibm.icu.math.BigDecimal(
01040: "12.65")).toString()).equals("12.65");
01041: (new Test("cst091")).ok = ((new com.ibm.icu.math.BigDecimal(
01042: "12.65E-20")).toString()).equals("1.265E-19");
01043: (new Test("cst092")).ok = ((new com.ibm.icu.math.BigDecimal(
01044: "12.65E-8")).toString()).equals("1.265E-7");
01045: (new Test("cst093")).ok = ((new com.ibm.icu.math.BigDecimal(
01046: "12.65E-4")).toString()).equals("1.265E-3");
01047: (new Test("cst094")).ok = ((new com.ibm.icu.math.BigDecimal(
01048: "12.65E-3")).toString()).equals("1.265E-2");
01049: (new Test("cst095")).ok = ((new com.ibm.icu.math.BigDecimal(
01050: "12.65E-2")).toString()).equals("1.265E-1");
01051: (new Test("cst096")).ok = ((new com.ibm.icu.math.BigDecimal(
01052: "12.65E-1")).toString()).equals("1.265");
01053: (new Test("cst097")).ok = ((new com.ibm.icu.math.BigDecimal(
01054: "12.65E-0")).toString()).equals("1.265E+1");
01055: (new Test("cst098")).ok = ((new com.ibm.icu.math.BigDecimal(
01056: "12.65E+1")).toString()).equals("1.265E+2");
01057: (new Test("cst099")).ok = ((new com.ibm.icu.math.BigDecimal(
01058: "12.65E+2")).toString()).equals("1.265E+3");
01059: (new Test("cst100")).ok = ((new com.ibm.icu.math.BigDecimal(
01060: "12.65E+3")).toString()).equals("1.265E+4");
01061: (new Test("cst101")).ok = ((new com.ibm.icu.math.BigDecimal(
01062: "12.65E+4")).toString()).equals("1.265E+5");
01063: (new Test("cst102")).ok = ((new com.ibm.icu.math.BigDecimal(
01064: "12.65E+8")).toString()).equals("1.265E+9");
01065: (new Test("cst103")).ok = ((new com.ibm.icu.math.BigDecimal(
01066: "12.65E+20")).toString()).equals("1.265E+21");
01067:
01068: (new Test("cst110")).ok = ((new com.ibm.icu.math.BigDecimal(
01069: "126.5")).toString()).equals("126.5");
01070: (new Test("cst111")).ok = ((new com.ibm.icu.math.BigDecimal(
01071: "126.5E-20")).toString()).equals("1.265E-18");
01072: (new Test("cst112")).ok = ((new com.ibm.icu.math.BigDecimal(
01073: "126.5E-8")).toString()).equals("1.265E-6");
01074: (new Test("cst113")).ok = ((new com.ibm.icu.math.BigDecimal(
01075: "126.5E-4")).toString()).equals("1.265E-2");
01076: (new Test("cst114")).ok = ((new com.ibm.icu.math.BigDecimal(
01077: "126.5E-3")).toString()).equals("1.265E-1");
01078: (new Test("cst115")).ok = ((new com.ibm.icu.math.BigDecimal(
01079: "126.5E-2")).toString()).equals("1.265");
01080: (new Test("cst116")).ok = ((new com.ibm.icu.math.BigDecimal(
01081: "126.5E-1")).toString()).equals("1.265E+1");
01082: (new Test("cst117")).ok = ((new com.ibm.icu.math.BigDecimal(
01083: "126.5E-0")).toString()).equals("1.265E+2");
01084: (new Test("cst118")).ok = ((new com.ibm.icu.math.BigDecimal(
01085: "126.5E+1")).toString()).equals("1.265E+3");
01086: (new Test("cst119")).ok = ((new com.ibm.icu.math.BigDecimal(
01087: "126.5E+2")).toString()).equals("1.265E+4");
01088: (new Test("cst120")).ok = ((new com.ibm.icu.math.BigDecimal(
01089: "126.5E+3")).toString()).equals("1.265E+5");
01090: (new Test("cst121")).ok = ((new com.ibm.icu.math.BigDecimal(
01091: "126.5E+4")).toString()).equals("1.265E+6");
01092: (new Test("cst122")).ok = ((new com.ibm.icu.math.BigDecimal(
01093: "126.5E+8")).toString()).equals("1.265E+10");
01094: (new Test("cst123")).ok = ((new com.ibm.icu.math.BigDecimal(
01095: "126.5E+20")).toString()).equals("1.265E+22");
01096:
01097: (new Test("cst130")).ok = ((new com.ibm.icu.math.BigDecimal(
01098: "1265")).toString()).equals("1265");
01099: (new Test("cst131")).ok = ((new com.ibm.icu.math.BigDecimal(
01100: "1265E-20")).toString()).equals("1.265E-17");
01101: (new Test("cst132")).ok = ((new com.ibm.icu.math.BigDecimal(
01102: "1265E-8")).toString()).equals("1.265E-5");
01103: (new Test("cst133")).ok = ((new com.ibm.icu.math.BigDecimal(
01104: "1265E-4")).toString()).equals("1.265E-1");
01105: (new Test("cst134")).ok = ((new com.ibm.icu.math.BigDecimal(
01106: "1265E-3")).toString()).equals("1.265");
01107: (new Test("cst135")).ok = ((new com.ibm.icu.math.BigDecimal(
01108: "1265E-2")).toString()).equals("1.265E+1");
01109: (new Test("cst136")).ok = ((new com.ibm.icu.math.BigDecimal(
01110: "1265E-1")).toString()).equals("1.265E+2");
01111: (new Test("cst137")).ok = ((new com.ibm.icu.math.BigDecimal(
01112: "1265E-0")).toString()).equals("1.265E+3");
01113: (new Test("cst138")).ok = ((new com.ibm.icu.math.BigDecimal(
01114: "1265E+1")).toString()).equals("1.265E+4");
01115: (new Test("cst139")).ok = ((new com.ibm.icu.math.BigDecimal(
01116: "1265E+2")).toString()).equals("1.265E+5");
01117: (new Test("cst140")).ok = ((new com.ibm.icu.math.BigDecimal(
01118: "1265E+3")).toString()).equals("1.265E+6");
01119: (new Test("cst141")).ok = ((new com.ibm.icu.math.BigDecimal(
01120: "1265E+4")).toString()).equals("1.265E+7");
01121: (new Test("cst142")).ok = ((new com.ibm.icu.math.BigDecimal(
01122: "1265E+8")).toString()).equals("1.265E+11");
01123: (new Test("cst143")).ok = ((new com.ibm.icu.math.BigDecimal(
01124: "1265E+20")).toString()).equals("1.265E+23");
01125:
01126: (new Test("cst150")).ok = ((new com.ibm.icu.math.BigDecimal(
01127: "0.1265")).toString()).equals("0.1265");
01128: (new Test("cst151")).ok = ((new com.ibm.icu.math.BigDecimal(
01129: "0.1265E-20")).toString()).equals("1.265E-21");
01130: (new Test("cst152")).ok = ((new com.ibm.icu.math.BigDecimal(
01131: "0.1265E-8")).toString()).equals("1.265E-9");
01132: (new Test("cst153")).ok = ((new com.ibm.icu.math.BigDecimal(
01133: "0.1265E-4")).toString()).equals("1.265E-5");
01134: (new Test("cst154")).ok = ((new com.ibm.icu.math.BigDecimal(
01135: "0.1265E-3")).toString()).equals("1.265E-4");
01136: (new Test("cst155")).ok = ((new com.ibm.icu.math.BigDecimal(
01137: "0.1265E-2")).toString()).equals("1.265E-3");
01138: (new Test("cst156")).ok = ((new com.ibm.icu.math.BigDecimal(
01139: "0.1265E-1")).toString()).equals("1.265E-2");
01140: (new Test("cst157")).ok = ((new com.ibm.icu.math.BigDecimal(
01141: "0.1265E-0")).toString()).equals("1.265E-1");
01142: (new Test("cst158")).ok = ((new com.ibm.icu.math.BigDecimal(
01143: "0.1265E+1")).toString()).equals("1.265");
01144: (new Test("cst159")).ok = ((new com.ibm.icu.math.BigDecimal(
01145: "0.1265E+2")).toString()).equals("1.265E+1");
01146: (new Test("cst160")).ok = ((new com.ibm.icu.math.BigDecimal(
01147: "0.1265E+3")).toString()).equals("1.265E+2");
01148: (new Test("cst161")).ok = ((new com.ibm.icu.math.BigDecimal(
01149: "0.1265E+4")).toString()).equals("1.265E+3");
01150: (new Test("cst162")).ok = ((new com.ibm.icu.math.BigDecimal(
01151: "0.1265E+8")).toString()).equals("1.265E+7");
01152: (new Test("cst163")).ok = ((new com.ibm.icu.math.BigDecimal(
01153: "0.1265E+20")).toString()).equals("1.265E+19");
01154:
01155: (new Test("cst170")).ok = ((new com.ibm.icu.math.BigDecimal(
01156: "0.09e999999999")).toString()).equals("9E+999999997");
01157: (new Test("cst171")).ok = ((new com.ibm.icu.math.BigDecimal(
01158: "0.9e999999999")).toString()).equals("9E+999999998");
01159: (new Test("cst172")).ok = ((new com.ibm.icu.math.BigDecimal(
01160: "9e999999999")).toString()).equals("9E+999999999");
01161: (new Test("cst173")).ok = ((new com.ibm.icu.math.BigDecimal(
01162: "9.9e999999999")).toString()).equals("9.9E+999999999");
01163: (new Test("cst174")).ok = ((new com.ibm.icu.math.BigDecimal(
01164: "9.99e999999999")).toString())
01165: .equals("9.99E+999999999");
01166: (new Test("cst175")).ok = ((new com.ibm.icu.math.BigDecimal(
01167: "9.99e-999999999")).toString())
01168: .equals("9.99E-999999999");
01169: (new Test("cst176")).ok = ((new com.ibm.icu.math.BigDecimal(
01170: "9.9e-999999999")).toString()).equals("9.9E-999999999");
01171: (new Test("cst177")).ok = ((new com.ibm.icu.math.BigDecimal(
01172: "9e-999999999")).toString()).equals("9E-999999999");
01173: (new Test("cst179")).ok = ((new com.ibm.icu.math.BigDecimal(
01174: "99e-999999999")).toString()).equals("9.9E-999999998");
01175: (new Test("cst180")).ok = ((new com.ibm.icu.math.BigDecimal(
01176: "999e-999999999")).toString())
01177: .equals("9.99E-999999997");
01178:
01179: // baddies --
01180: badstrings = new java.lang.String[] { "1..2", ".", "..", "++1",
01181: "--1", "-+1", "+-1", "12e", "12e++", "12f4", " +1",
01182: "+ 1", "12 ", " + 1", " - 1 ", "x", "-1-", "12-", "3+",
01183: "", "1e-", "7e1000000000", "", "e100", "\u0e5a",
01184: "\u0b65", "99e999999999", "999e999999999",
01185: "0.9e-999999999", "0.09e-999999999", "0.1e1000000000",
01186: "10e-1000000000", "0.9e9999999999", "99e-9999999999",
01187: "111e9999999999",
01188: "1111e-9999999999" + " " + "111e*123", "111e123-",
01189: "111e+12+", "111e1-3-", "111e1*23", "111e1e+3",
01190: "1e1.0", "1e123e", "ten", "ONE", "1e.1", "1e1.", "1ee",
01191: "e+1" }; // 200-203
01192: // 204-207
01193: // 208-211
01194: // 211-214
01195: // 215-219
01196: // 220-222
01197: // 223-224
01198: // 225-226
01199: // 227-228
01200: // 229-230
01201: // 231-232
01202: // 233-234
01203: // 235-237
01204: // 238-240
01205: // 241-244
01206: // 245-248
01207:
01208: // watch out for commas on continuation lines
01209:
01210: {
01211: int $16 = badstrings.length;
01212: i = 0;
01213: i: for (; $16 > 0; $16--, i++) {
01214: try {
01215: new com.ibm.icu.math.BigDecimal(badstrings[i]);
01216: say(">>> cst"
01217: + (200 + i)
01218: + ":"
01219: + " "
01220: + badstrings[i]
01221: + " "
01222: + (new com.ibm.icu.math.BigDecimal(
01223: badstrings[i])).toString());
01224: flag = false;
01225: } catch (java.lang.NumberFormatException $17) {
01226: flag = true;
01227: }
01228: (new Test("cst" + (200 + i))).ok = flag;
01229: }
01230: }/*i*/
01231:
01232: try {
01233: checknull: do {
01234: new com.ibm.icu.math.BigDecimal((java.lang.String) null);
01235: flag = false;
01236: } while (false);
01237: } catch (java.lang.NullPointerException $18) {
01238: flag = true;
01239: }/*checknull*/
01240: (new Test("cst301")).ok = flag;
01241:
01242: summary("Constructors");
01243: return;
01244: }
01245:
01246: /** Mutation tests (checks that contents of constant objects are unchanged). */
01247:
01248: public void diagmutation() {
01249: /* ---------------------------------------------------------------- */
01250: /* Final tests -- check constants haven't mutated */
01251: /* -- also that MC objects haven't mutated */
01252: /* ---------------------------------------------------------------- */
01253: (new Test("cuc001")).ok = (com.ibm.icu.math.BigDecimal.ZERO
01254: .toString()).equals("0");
01255: (new Test("cuc002")).ok = (com.ibm.icu.math.BigDecimal.ONE
01256: .toString()).equals("1");
01257: (new Test("cuc003")).ok = (com.ibm.icu.math.BigDecimal.TEN
01258: .toString()).equals("10");
01259:
01260: (new Test("cuc010")).ok = com.ibm.icu.math.BigDecimal.ROUND_CEILING == com.ibm.icu.math.MathContext.ROUND_CEILING;
01261: (new Test("cuc011")).ok = com.ibm.icu.math.BigDecimal.ROUND_DOWN == com.ibm.icu.math.MathContext.ROUND_DOWN;
01262: (new Test("cuc012")).ok = com.ibm.icu.math.BigDecimal.ROUND_FLOOR == com.ibm.icu.math.MathContext.ROUND_FLOOR;
01263: (new Test("cuc013")).ok = com.ibm.icu.math.BigDecimal.ROUND_HALF_DOWN == com.ibm.icu.math.MathContext.ROUND_HALF_DOWN;
01264: (new Test("cuc014")).ok = com.ibm.icu.math.BigDecimal.ROUND_HALF_EVEN == com.ibm.icu.math.MathContext.ROUND_HALF_EVEN;
01265: (new Test("cuc015")).ok = com.ibm.icu.math.BigDecimal.ROUND_HALF_UP == com.ibm.icu.math.MathContext.ROUND_HALF_UP;
01266: (new Test("cuc016")).ok = com.ibm.icu.math.BigDecimal.ROUND_UNNECESSARY == com.ibm.icu.math.MathContext.ROUND_UNNECESSARY;
01267: (new Test("cuc017")).ok = com.ibm.icu.math.BigDecimal.ROUND_UP == com.ibm.icu.math.MathContext.ROUND_UP;
01268:
01269: (new Test("cuc020")).ok = (com.ibm.icu.math.MathContext.DEFAULT
01270: .getDigits()) == 9;
01271: (new Test("cuc021")).ok = (com.ibm.icu.math.MathContext.DEFAULT
01272: .getForm()) == com.ibm.icu.math.MathContext.SCIENTIFIC;
01273: (new Test("cuc022")).ok = (com.ibm.icu.math.MathContext.DEFAULT
01274: .getLostDigits() ? 1 : 0) == 0;
01275: (new Test("cuc023")).ok = (com.ibm.icu.math.MathContext.DEFAULT
01276: .getRoundingMode()) == com.ibm.icu.math.MathContext.ROUND_HALF_UP;
01277:
01278: // mc9 =MathContext(9)
01279: // mcld =MathContext(9, SCIENTIFIC, 1)
01280: // mcfd =MathContext(0, PLAIN)
01281: (new Test("cuc030")).ok = (mc9.getDigits()) == 9;
01282: (new Test("cuc031")).ok = (mc9.getForm()) == com.ibm.icu.math.MathContext.SCIENTIFIC;
01283: (new Test("cuc032")).ok = (mc9.getLostDigits() ? 1 : 0) == 0;
01284: (new Test("cuc033")).ok = (mc9.getRoundingMode()) == com.ibm.icu.math.MathContext.ROUND_HALF_UP;
01285: (new Test("cuc034")).ok = (mcld.getDigits()) == 9;
01286: (new Test("cuc035")).ok = (mcld.getForm()) == com.ibm.icu.math.MathContext.SCIENTIFIC;
01287: (new Test("cuc036")).ok = (mcld.getLostDigits() ? 1 : 0) == 1;
01288: (new Test("cuc037")).ok = (mcld.getRoundingMode()) == com.ibm.icu.math.MathContext.ROUND_HALF_UP;
01289: (new Test("cuc038")).ok = (mcfd.getDigits()) == 0;
01290: (new Test("cuc039")).ok = (mcfd.getForm()) == com.ibm.icu.math.MathContext.PLAIN;
01291: (new Test("cuc040")).ok = (mcfd.getLostDigits() ? 1 : 0) == 0;
01292: (new Test("cuc041")).ok = (mcfd.getRoundingMode()) == com.ibm.icu.math.MathContext.ROUND_HALF_UP;
01293:
01294: summary("No mutation");
01295: }
01296:
01297: /* ----------------------------------------------------------------- */
01298: /* Operator test methods */
01299: /* ----------------------------------------------------------------- */
01300: // The use of context in these tests are primarily to show that they
01301: // are correctly passed to the methods, except that we check that
01302: // each method checks for lostDigits.
01303: /** Test the {@link com.ibm.icu.math.BigDecimal#abs} method. */
01304:
01305: public void diagabs() {
01306: boolean flag = false;
01307: java.lang.ArithmeticException ae = null;
01308:
01309: // most of the function of this is tested by add
01310: (new Test("abs001")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
01311: .abs().toString()).equals("2");
01312: (new Test("abs002")).ok = ((new com.ibm.icu.math.BigDecimal(
01313: "-2")).abs().toString()).equals("2");
01314: (new Test("abs003")).ok = ((new com.ibm.icu.math.BigDecimal(
01315: "+0.000")).abs().toString()).equals("0.000");
01316: (new Test("abs004")).ok = ((new com.ibm.icu.math.BigDecimal(
01317: "00.000")).abs().toString()).equals("0.000");
01318: (new Test("abs005")).ok = ((new com.ibm.icu.math.BigDecimal(
01319: "-0.000")).abs().toString()).equals("0.000");
01320: (new Test("abs006")).ok = ((new com.ibm.icu.math.BigDecimal(
01321: "+0.000")).abs(mcdef).toString()).equals("0");
01322: (new Test("abs007")).ok = ((new com.ibm.icu.math.BigDecimal(
01323: "00.000")).abs(mcdef).toString()).equals("0");
01324: (new Test("abs008")).ok = ((new com.ibm.icu.math.BigDecimal(
01325: "-0.000")).abs(mcdef).toString()).equals("0");
01326: (new Test("abs009")).ok = ((new com.ibm.icu.math.BigDecimal(
01327: "-2000000")).abs().toString()).equals("2000000");
01328: (new Test("abs010")).ok = ((new com.ibm.icu.math.BigDecimal(
01329: "-2000000")).abs(mcdef).toString()).equals("2000000");
01330: (new Test("abs011")).ok = ((new com.ibm.icu.math.BigDecimal(
01331: "-2000000")).abs(mc6).toString()).equals("2.00000E+6");
01332: (new Test("abs012")).ok = ((new com.ibm.icu.math.BigDecimal(
01333: "2000000")).abs(mc6).toString()).equals("2.00000E+6");
01334: (new Test("abs013")).ok = ((new com.ibm.icu.math.BigDecimal(
01335: "0.2")).abs().toString()).equals("0.2");
01336: (new Test("abs014")).ok = ((new com.ibm.icu.math.BigDecimal(
01337: "-0.2")).abs().toString()).equals("0.2");
01338: (new Test("abs015")).ok = ((new com.ibm.icu.math.BigDecimal(
01339: "0.01")).abs().toString()).equals("0.01");
01340: (new Test("abs016")).ok = ((new com.ibm.icu.math.BigDecimal(
01341: "-0.01")).abs().toString()).equals("0.01");
01342: try {
01343: checkdigits: do {
01344: tenlong.abs(mcld);
01345: flag = false;
01346: } while (false);
01347: } catch (java.lang.ArithmeticException $19) {
01348: ae = $19;
01349: flag = (ae.getMessage()).equals("Too many digits:" + " "
01350: + tenlong.toString());
01351: }/*checkdigits*/
01352: (new Test("abs020")).ok = flag;
01353: // check lostdigits not raised if digits=0 [monadic method]
01354: try {
01355: checkdigits: do {
01356: tenlong.abs(mcld0);
01357: flag = true;
01358: } while (false);
01359: } catch (java.lang.ArithmeticException $20) {
01360: ae = $20;
01361: flag = false;
01362: }/*checkdigits*/
01363: (new Test("abs021")).ok = flag;
01364: try {
01365: checknull: do {
01366: com.ibm.icu.math.BigDecimal.TEN
01367: .abs((com.ibm.icu.math.MathContext) null);
01368: flag = false;
01369: } while (false);
01370: } catch (java.lang.NullPointerException $21) {
01371: flag = true;
01372: }/*checknull*/
01373: (new Test("abs022")).ok = flag;
01374:
01375: summary("abs");
01376: }
01377:
01378: /* ----------------------------------------------------------------- */
01379:
01380: /** Test the {@link com.ibm.icu.math.BigDecimal#add} method. */
01381:
01382: public void diagadd() {
01383: boolean flag = false;
01384: com.ibm.icu.math.BigDecimal alhs;
01385: com.ibm.icu.math.BigDecimal arhs;
01386: java.lang.ArithmeticException ae = null;
01387:
01388: // [first group are 'quick confidence check']
01389: (new Test("add001")).ok = ((new com.ibm.icu.math.BigDecimal(2))
01390: .add(new com.ibm.icu.math.BigDecimal(3), mcdef)
01391: .toString()).equals("5");
01392: (new Test("add003")).ok = ((new com.ibm.icu.math.BigDecimal(
01393: "5.75")).add(new com.ibm.icu.math.BigDecimal("3.3"),
01394: mcdef).toString()).equals("9.05");
01395: (new Test("add004")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
01396: .add(new com.ibm.icu.math.BigDecimal("-3"), mcdef)
01397: .toString()).equals("2");
01398: (new Test("add005")).ok = ((new com.ibm.icu.math.BigDecimal(
01399: "-5"))
01400: .add(new com.ibm.icu.math.BigDecimal("-3"), mcdef)
01401: .toString()).equals("-8");
01402: (new Test("add006")).ok = ((new com.ibm.icu.math.BigDecimal(
01403: "-7")).add(new com.ibm.icu.math.BigDecimal("2.5"),
01404: mcdef).toString()).equals("-4.5");
01405: (new Test("add007")).ok = ((new com.ibm.icu.math.BigDecimal(
01406: "0.7")).add(new com.ibm.icu.math.BigDecimal("0.3"),
01407: mcdef).toString()).equals("1.0");
01408: (new Test("add008")).ok = ((new com.ibm.icu.math.BigDecimal(
01409: "1.25")).add(new com.ibm.icu.math.BigDecimal("1.25"),
01410: mcdef).toString()).equals("2.50");
01411: (new Test("add009")).ok = ((new com.ibm.icu.math.BigDecimal(
01412: "1.23456789")).add(new com.ibm.icu.math.BigDecimal(
01413: "1.00000000"), mcdef).toString()).equals("2.23456789");
01414:
01415: (new Test("add010")).ok = ((new com.ibm.icu.math.BigDecimal(
01416: "1.23456789")).add(new com.ibm.icu.math.BigDecimal(
01417: "1.00000011"), mcdef).toString()).equals("2.23456800");
01418:
01419: (new Test("add011")).ok = ((new com.ibm.icu.math.BigDecimal(
01420: "0.4444444444")).add(new com.ibm.icu.math.BigDecimal(
01421: "0.5555555555"), mcdef).toString())
01422: .equals("1.00000000");
01423:
01424: (new Test("add012")).ok = ((new com.ibm.icu.math.BigDecimal(
01425: "0.4444444440")).add(new com.ibm.icu.math.BigDecimal(
01426: "0.5555555555"), mcdef).toString())
01427: .equals("1.00000000");
01428:
01429: (new Test("add013")).ok = ((new com.ibm.icu.math.BigDecimal(
01430: "0.4444444444")).add(new com.ibm.icu.math.BigDecimal(
01431: "0.5555555550"), mcdef).toString())
01432: .equals("0.999999999");
01433:
01434: (new Test("add014")).ok = ((new com.ibm.icu.math.BigDecimal(
01435: "0.4444444444999")).add(
01436: new com.ibm.icu.math.BigDecimal("0"), mcdef).toString())
01437: .equals("0.444444444");
01438:
01439: (new Test("add015")).ok = ((new com.ibm.icu.math.BigDecimal(
01440: "0.4444444445000")).add(
01441: new com.ibm.icu.math.BigDecimal("0"), mcdef).toString())
01442: .equals("0.444444445");
01443:
01444: (new Test("add016")).ok = ((new com.ibm.icu.math.BigDecimal(
01445: "70")).add(new com.ibm.icu.math.BigDecimal("10000e+9"),
01446: mcdef).toString()).equals("1.00000000E+13");
01447:
01448: (new Test("add017")).ok = ((new com.ibm.icu.math.BigDecimal(
01449: "700")).add(
01450: new com.ibm.icu.math.BigDecimal("10000e+9"), mcdef)
01451: .toString()).equals("1.00000000E+13");
01452:
01453: (new Test("add018")).ok = ((new com.ibm.icu.math.BigDecimal(
01454: "7000")).add(
01455: new com.ibm.icu.math.BigDecimal("10000e+9"), mcdef)
01456: .toString()).equals("1.00000000E+13");
01457:
01458: (new Test("add019")).ok = ((new com.ibm.icu.math.BigDecimal(
01459: "70000")).add(new com.ibm.icu.math.BigDecimal(
01460: "10000e+9"), mcdef).toString())
01461: .equals("1.00000001E+13");
01462:
01463: (new Test("add020")).ok = ((new com.ibm.icu.math.BigDecimal(
01464: "700000")).add(new com.ibm.icu.math.BigDecimal(
01465: "10000e+9"), mcdef).toString())
01466: .equals("1.00000007E+13");
01467:
01468: // [Now the same group with fixed arithmetic]
01469: (new Test("add030")).ok = ((new com.ibm.icu.math.BigDecimal(2))
01470: .add(new com.ibm.icu.math.BigDecimal(3)).toString())
01471: .equals("5");
01472: (new Test("add031")).ok = ((new com.ibm.icu.math.BigDecimal(
01473: "5.75")).add(new com.ibm.icu.math.BigDecimal("3.3"))
01474: .toString()).equals("9.05");
01475: (new Test("add032")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
01476: .add(new com.ibm.icu.math.BigDecimal("-3")).toString())
01477: .equals("2");
01478: (new Test("add033")).ok = ((new com.ibm.icu.math.BigDecimal(
01479: "-5")).add(new com.ibm.icu.math.BigDecimal("-3"))
01480: .toString()).equals("-8");
01481: (new Test("add034")).ok = ((new com.ibm.icu.math.BigDecimal(
01482: "-7")).add(new com.ibm.icu.math.BigDecimal("2.5"))
01483: .toString()).equals("-4.5");
01484: (new Test("add035")).ok = ((new com.ibm.icu.math.BigDecimal(
01485: "0.7")).add(new com.ibm.icu.math.BigDecimal("0.3"))
01486: .toString()).equals("1.0");
01487: (new Test("add036")).ok = ((new com.ibm.icu.math.BigDecimal(
01488: "1.25")).add(new com.ibm.icu.math.BigDecimal("1.25"))
01489: .toString()).equals("2.50");
01490: (new Test("add037")).ok = ((new com.ibm.icu.math.BigDecimal(
01491: "1.23456789")).add(new com.ibm.icu.math.BigDecimal(
01492: "1.00000000")).toString()).equals("2.23456789");
01493:
01494: (new Test("add038")).ok = ((new com.ibm.icu.math.BigDecimal(
01495: "1.23456789")).add(new com.ibm.icu.math.BigDecimal(
01496: "1.00000011")).toString()).equals("2.23456800");
01497:
01498: (new Test("add039")).ok = ((new com.ibm.icu.math.BigDecimal(
01499: "0.4444444444")).add(new com.ibm.icu.math.BigDecimal(
01500: "0.5555555555")).toString()).equals("0.9999999999");
01501:
01502: (new Test("add040")).ok = ((new com.ibm.icu.math.BigDecimal(
01503: "0.4444444440")).add(new com.ibm.icu.math.BigDecimal(
01504: "0.5555555555")).toString()).equals("0.9999999995");
01505:
01506: (new Test("add041")).ok = ((new com.ibm.icu.math.BigDecimal(
01507: "0.4444444444")).add(new com.ibm.icu.math.BigDecimal(
01508: "0.5555555550")).toString()).equals("0.9999999994");
01509:
01510: (new Test("add042")).ok = ((new com.ibm.icu.math.BigDecimal(
01511: "0.4444444444999"))
01512: .add(new com.ibm.icu.math.BigDecimal("0")).toString())
01513: .equals("0.4444444444999");
01514:
01515: (new Test("add043")).ok = ((new com.ibm.icu.math.BigDecimal(
01516: "0.4444444445000"))
01517: .add(new com.ibm.icu.math.BigDecimal("0")).toString())
01518: .equals("0.4444444445000");
01519:
01520: (new Test("add044")).ok = ((new com.ibm.icu.math.BigDecimal(
01521: "70")).add(new com.ibm.icu.math.BigDecimal("10000e+9"))
01522: .toString()).equals("10000000000070");
01523:
01524: (new Test("add045")).ok = ((new com.ibm.icu.math.BigDecimal(
01525: "700"))
01526: .add(new com.ibm.icu.math.BigDecimal("10000e+9"))
01527: .toString()).equals("10000000000700");
01528:
01529: (new Test("add046")).ok = ((new com.ibm.icu.math.BigDecimal(
01530: "7000"))
01531: .add(new com.ibm.icu.math.BigDecimal("10000e+9"))
01532: .toString()).equals("10000000007000");
01533:
01534: (new Test("add047")).ok = ((new com.ibm.icu.math.BigDecimal(
01535: "70000")).add(new com.ibm.icu.math.BigDecimal(
01536: "10000e+9")).toString()).equals("10000000070000");
01537:
01538: (new Test("add048")).ok = ((new com.ibm.icu.math.BigDecimal(
01539: "700000")).add(new com.ibm.icu.math.BigDecimal(
01540: "10000e+9")).toString()).equals("10000000700000");
01541:
01542: // symmetry:
01543: (new Test("add049")).ok = ((new com.ibm.icu.math.BigDecimal(
01544: "10000e+9")).add(new com.ibm.icu.math.BigDecimal("70"),
01545: mcdef).toString()).equals("1.00000000E+13");
01546:
01547: (new Test("add050")).ok = ((new com.ibm.icu.math.BigDecimal(
01548: "10000e+9")).add(
01549: new com.ibm.icu.math.BigDecimal("700"), mcdef)
01550: .toString()).equals("1.00000000E+13");
01551:
01552: (new Test("add051")).ok = ((new com.ibm.icu.math.BigDecimal(
01553: "10000e+9")).add(
01554: new com.ibm.icu.math.BigDecimal("7000"), mcdef)
01555: .toString()).equals("1.00000000E+13");
01556:
01557: (new Test("add052")).ok = ((new com.ibm.icu.math.BigDecimal(
01558: "10000e+9")).add(new com.ibm.icu.math.BigDecimal(
01559: "70000"), mcdef).toString()).equals("1.00000001E+13");
01560:
01561: (new Test("add053")).ok = ((new com.ibm.icu.math.BigDecimal(
01562: "10000e+9")).add(new com.ibm.icu.math.BigDecimal(
01563: "700000"), mcdef).toString()).equals("1.00000007E+13");
01564:
01565: (new Test("add054")).ok = ((new com.ibm.icu.math.BigDecimal(
01566: "10000e+9")).add(new com.ibm.icu.math.BigDecimal("70"))
01567: .toString()).equals("10000000000070");
01568:
01569: (new Test("add055")).ok = ((new com.ibm.icu.math.BigDecimal(
01570: "10000e+9"))
01571: .add(new com.ibm.icu.math.BigDecimal("700")).toString())
01572: .equals("10000000000700");
01573:
01574: (new Test("add056")).ok = ((new com.ibm.icu.math.BigDecimal(
01575: "10000e+9"))
01576: .add(new com.ibm.icu.math.BigDecimal("7000"))
01577: .toString()).equals("10000000007000");
01578:
01579: (new Test("add057")).ok = ((new com.ibm.icu.math.BigDecimal(
01580: "10000e+9")).add(new com.ibm.icu.math.BigDecimal(
01581: "70000")).toString()).equals("10000000070000");
01582:
01583: (new Test("add058")).ok = ((new com.ibm.icu.math.BigDecimal(
01584: "10000e+9")).add(new com.ibm.icu.math.BigDecimal(
01585: "700000")).toString()).equals("10000000700000");
01586:
01587: // some rounding effects
01588: (new Test("add059")).ok = ((new com.ibm.icu.math.BigDecimal(
01589: "0.9998"))
01590: .add(new com.ibm.icu.math.BigDecimal("0.0000"))
01591: .toString()).equals("0.9998");
01592:
01593: (new Test("add060")).ok = ((new com.ibm.icu.math.BigDecimal(
01594: "0.9998"))
01595: .add(new com.ibm.icu.math.BigDecimal("0.0001"))
01596: .toString()).equals("0.9999");
01597:
01598: (new Test("add061")).ok = ((new com.ibm.icu.math.BigDecimal(
01599: "0.9998"))
01600: .add(new com.ibm.icu.math.BigDecimal("0.0002"))
01601: .toString()).equals("1.0000");
01602:
01603: (new Test("add062")).ok = ((new com.ibm.icu.math.BigDecimal(
01604: "0.9998"))
01605: .add(new com.ibm.icu.math.BigDecimal("0.0003"))
01606: .toString()).equals("1.0001");
01607:
01608: // MC
01609: (new Test("add070")).ok = ((new com.ibm.icu.math.BigDecimal(
01610: "10000e+9")).add(new com.ibm.icu.math.BigDecimal(
01611: "70000"), mcfd).toString()).equals("10000000070000");
01612:
01613: (new Test("add071")).ok = ((new com.ibm.icu.math.BigDecimal(
01614: "10000e+9")).add(new com.ibm.icu.math.BigDecimal(
01615: "70000"), mcdef).toString()).equals("1.00000001E+13");
01616:
01617: (new Test("add072")).ok = ((new com.ibm.icu.math.BigDecimal(
01618: "10000e+9")).add(new com.ibm.icu.math.BigDecimal(
01619: "70000"), mc6).toString()).equals("1.00000E+13");
01620:
01621: // zero preservation
01622: (new Test("add080")).ok = (com.ibm.icu.math.BigDecimal.ONE.add(
01623: new com.ibm.icu.math.BigDecimal("0.0001"), mc6)
01624: .toString()).equals("1.0001");
01625:
01626: (new Test("add081")).ok = (com.ibm.icu.math.BigDecimal.ONE.add(
01627: new com.ibm.icu.math.BigDecimal("0.00001"), mc6)
01628: .toString()).equals("1.00001");
01629:
01630: (new Test("add082")).ok = (com.ibm.icu.math.BigDecimal.ONE.add(
01631: new com.ibm.icu.math.BigDecimal("0.000001"), mc6)
01632: .toString()).equals("1.00000");
01633:
01634: (new Test("add083")).ok = (com.ibm.icu.math.BigDecimal.ONE.add(
01635: new com.ibm.icu.math.BigDecimal("0.0000001"), mc6)
01636: .toString()).equals("1.00000");
01637:
01638: (new Test("add084")).ok = (com.ibm.icu.math.BigDecimal.ONE.add(
01639: new com.ibm.icu.math.BigDecimal("0.00000001"), mc6)
01640: .toString()).equals("1.00000");
01641:
01642: // more fixed, LHS swaps
01643: (new Test("add090")).ok = ((new com.ibm.icu.math.BigDecimal(
01644: "-56267E-10")).add(zero).toString())
01645: .equals("-0.0000056267");
01646: (new Test("add091")).ok = ((new com.ibm.icu.math.BigDecimal(
01647: "-56267E-6")).add(zero).toString()).equals("-0.056267");
01648: (new Test("add092")).ok = ((new com.ibm.icu.math.BigDecimal(
01649: "-56267E-5")).add(zero).toString()).equals("-0.56267");
01650: (new Test("add093")).ok = ((new com.ibm.icu.math.BigDecimal(
01651: "-56267E-4")).add(zero).toString()).equals("-5.6267");
01652: (new Test("add094")).ok = ((new com.ibm.icu.math.BigDecimal(
01653: "-56267E-3")).add(zero).toString()).equals("-56.267");
01654: (new Test("add095")).ok = ((new com.ibm.icu.math.BigDecimal(
01655: "-56267E-2")).add(zero).toString()).equals("-562.67");
01656: (new Test("add096")).ok = ((new com.ibm.icu.math.BigDecimal(
01657: "-56267E-1")).add(zero).toString()).equals("-5626.7");
01658: (new Test("add097")).ok = ((new com.ibm.icu.math.BigDecimal(
01659: "-56267E-0")).add(zero).toString()).equals("-56267");
01660: (new Test("add098")).ok = ((new com.ibm.icu.math.BigDecimal(
01661: "-5E-10")).add(zero).toString())
01662: .equals("-0.0000000005");
01663: (new Test("add099")).ok = ((new com.ibm.icu.math.BigDecimal(
01664: "-5E-5")).add(zero).toString()).equals("-0.00005");
01665: (new Test("add100")).ok = ((new com.ibm.icu.math.BigDecimal(
01666: "-5E-1")).add(zero).toString()).equals("-0.5");
01667: (new Test("add101")).ok = ((new com.ibm.icu.math.BigDecimal(
01668: "-5E-10")).add(zero).toString())
01669: .equals("-0.0000000005");
01670: (new Test("add102")).ok = ((new com.ibm.icu.math.BigDecimal(
01671: "-5E-5")).add(zero).toString()).equals("-0.00005");
01672: (new Test("add103")).ok = ((new com.ibm.icu.math.BigDecimal(
01673: "-5E-1")).add(zero).toString()).equals("-0.5");
01674: (new Test("add104")).ok = ((new com.ibm.icu.math.BigDecimal(
01675: "-5E10")).add(zero).toString()).equals("-50000000000");
01676: (new Test("add105")).ok = ((new com.ibm.icu.math.BigDecimal(
01677: "-5E5")).add(zero).toString()).equals("-500000");
01678: (new Test("add106")).ok = ((new com.ibm.icu.math.BigDecimal(
01679: "-5E1")).add(zero).toString()).equals("-50");
01680: (new Test("add107")).ok = ((new com.ibm.icu.math.BigDecimal(
01681: "-5E0")).add(zero).toString()).equals("-5");
01682:
01683: // more fixed, RHS swaps
01684: (new Test("add108")).ok = (zero
01685: .add(new com.ibm.icu.math.BigDecimal("-56267E-10"))
01686: .toString()).equals("-0.0000056267");
01687: (new Test("add109")).ok = (zero
01688: .add(new com.ibm.icu.math.BigDecimal("-56267E-6"))
01689: .toString()).equals("-0.056267");
01690: (new Test("add110")).ok = (zero
01691: .add(new com.ibm.icu.math.BigDecimal("-56267E-5"))
01692: .toString()).equals("-0.56267");
01693: (new Test("add111")).ok = (zero
01694: .add(new com.ibm.icu.math.BigDecimal("-56267E-4"))
01695: .toString()).equals("-5.6267");
01696: (new Test("add112")).ok = (zero
01697: .add(new com.ibm.icu.math.BigDecimal("-56267E-3"))
01698: .toString()).equals("-56.267");
01699: (new Test("add113")).ok = (zero
01700: .add(new com.ibm.icu.math.BigDecimal("-56267E-2"))
01701: .toString()).equals("-562.67");
01702: (new Test("add114")).ok = (zero
01703: .add(new com.ibm.icu.math.BigDecimal("-56267E-1"))
01704: .toString()).equals("-5626.7");
01705: (new Test("add115")).ok = (zero
01706: .add(new com.ibm.icu.math.BigDecimal("-56267E-0"))
01707: .toString()).equals("-56267");
01708: (new Test("add116")).ok = (zero
01709: .add(new com.ibm.icu.math.BigDecimal("-5E-10"))
01710: .toString()).equals("-0.0000000005");
01711: (new Test("add117")).ok = (zero
01712: .add(new com.ibm.icu.math.BigDecimal("-5E-5"))
01713: .toString()).equals("-0.00005");
01714: (new Test("add118")).ok = (zero
01715: .add(new com.ibm.icu.math.BigDecimal("-5E-1"))
01716: .toString()).equals("-0.5");
01717: (new Test("add129")).ok = (zero
01718: .add(new com.ibm.icu.math.BigDecimal("-5E-10"))
01719: .toString()).equals("-0.0000000005");
01720: (new Test("add130")).ok = (zero
01721: .add(new com.ibm.icu.math.BigDecimal("-5E-5"))
01722: .toString()).equals("-0.00005");
01723: (new Test("add131")).ok = (zero
01724: .add(new com.ibm.icu.math.BigDecimal("-5E-1"))
01725: .toString()).equals("-0.5");
01726: (new Test("add132")).ok = (zero
01727: .add(new com.ibm.icu.math.BigDecimal("-5E10"))
01728: .toString()).equals("-50000000000");
01729: (new Test("add133")).ok = (zero
01730: .add(new com.ibm.icu.math.BigDecimal("-5E5"))
01731: .toString()).equals("-500000");
01732: (new Test("add134")).ok = (zero
01733: .add(new com.ibm.icu.math.BigDecimal("-5E1"))
01734: .toString()).equals("-50");
01735: (new Test("add135")).ok = (zero
01736: .add(new com.ibm.icu.math.BigDecimal("-5E0"))
01737: .toString()).equals("-5");
01738:
01739: // [some of the next group are really constructor tests]
01740: (new Test("add140")).ok = ((new com.ibm.icu.math.BigDecimal(
01741: "00.0")).add(new com.ibm.icu.math.BigDecimal("0.00"),
01742: mcdef).toString()).equals("0");
01743: (new Test("add141")).ok = ((new com.ibm.icu.math.BigDecimal(
01744: "0.00")).add(new com.ibm.icu.math.BigDecimal("00.0"),
01745: mcdef).toString()).equals("0");
01746: (new Test("add142")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
01747: .add(new com.ibm.icu.math.BigDecimal(".3"), mcdef)
01748: .toString()).equals("3.3");
01749: (new Test("add143")).ok = ((new com.ibm.icu.math.BigDecimal(
01750: "3."))
01751: .add(new com.ibm.icu.math.BigDecimal(".3"), mcdef)
01752: .toString()).equals("3.3");
01753: (new Test("add144")).ok = ((new com.ibm.icu.math.BigDecimal(
01754: "3.0")).add(new com.ibm.icu.math.BigDecimal(".3"),
01755: mcdef).toString()).equals("3.3");
01756: (new Test("add145")).ok = ((new com.ibm.icu.math.BigDecimal(
01757: "3.00")).add(new com.ibm.icu.math.BigDecimal(".3"),
01758: mcdef).toString()).equals("3.30");
01759: (new Test("add146")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
01760: .add(new com.ibm.icu.math.BigDecimal("3"), mcdef)
01761: .toString()).equals("6");
01762: (new Test("add147")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
01763: .add(new com.ibm.icu.math.BigDecimal("+3"), mcdef)
01764: .toString()).equals("6");
01765: (new Test("add148")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
01766: .add(new com.ibm.icu.math.BigDecimal("-3"), mcdef)
01767: .toString()).equals("0");
01768: (new Test("add149")).ok = ((new com.ibm.icu.math.BigDecimal(
01769: "0.03")).add(new com.ibm.icu.math.BigDecimal("-0.03"),
01770: mcdef).toString()).equals("0");
01771:
01772: (new Test("add150")).ok = ((new com.ibm.icu.math.BigDecimal(
01773: "00.0")).add(new com.ibm.icu.math.BigDecimal("0.00"))
01774: .toString()).equals("0.00");
01775: (new Test("add151")).ok = ((new com.ibm.icu.math.BigDecimal(
01776: "0.00")).add(new com.ibm.icu.math.BigDecimal("00.0"))
01777: .toString()).equals("0.00");
01778: (new Test("add152")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
01779: .add(new com.ibm.icu.math.BigDecimal(".3")).toString())
01780: .equals("3.3");
01781: (new Test("add153")).ok = ((new com.ibm.icu.math.BigDecimal(
01782: "3.")).add(new com.ibm.icu.math.BigDecimal(".3"))
01783: .toString()).equals("3.3");
01784: (new Test("add154")).ok = ((new com.ibm.icu.math.BigDecimal(
01785: "3.0")).add(new com.ibm.icu.math.BigDecimal(".3"))
01786: .toString()).equals("3.3");
01787: (new Test("add155")).ok = ((new com.ibm.icu.math.BigDecimal(
01788: "3.00")).add(new com.ibm.icu.math.BigDecimal(".3"))
01789: .toString()).equals("3.30");
01790: (new Test("add156")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
01791: .add(new com.ibm.icu.math.BigDecimal("3")).toString())
01792: .equals("6");
01793: (new Test("add157")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
01794: .add(new com.ibm.icu.math.BigDecimal("+3")).toString())
01795: .equals("6");
01796: (new Test("add158")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
01797: .add(new com.ibm.icu.math.BigDecimal("-3")).toString())
01798: .equals("0");
01799: (new Test("add159")).ok = ((new com.ibm.icu.math.BigDecimal(
01800: "0.3")).add(new com.ibm.icu.math.BigDecimal("-0.3"))
01801: .toString()).equals("0.0");
01802: (new Test("add160")).ok = ((new com.ibm.icu.math.BigDecimal(
01803: "0.03")).add(new com.ibm.icu.math.BigDecimal("-0.03"))
01804: .toString()).equals("0.00");
01805: (new Test("add161")).ok = ((new com.ibm.icu.math.BigDecimal(
01806: "7E+12")).add(new com.ibm.icu.math.BigDecimal("-1"),
01807: mcfd).toString()).equals("6999999999999");
01808:
01809: (new Test("add162")).ok = ((new com.ibm.icu.math.BigDecimal(
01810: "7E+12")).add(new com.ibm.icu.math.BigDecimal("1.11"),
01811: mcfd).toString()).equals("7000000000001.11");
01812:
01813: (new Test("add163")).ok = ((new com.ibm.icu.math.BigDecimal(
01814: "1.11")).add(new com.ibm.icu.math.BigDecimal("7E+12"),
01815: mcfd).toString()).equals("7000000000001.11");
01816:
01817: // input preparation tests
01818: alhs = new com.ibm.icu.math.BigDecimal("12345678900000");
01819: arhs = new com.ibm.icu.math.BigDecimal("9999999999999");
01820: (new Test("add170")).ok = (alhs.add(arhs, mc3).toString())
01821: .equals("2.23E+13");
01822: (new Test("add171")).ok = (arhs.add(alhs, mc3).toString())
01823: .equals("2.23E+13");
01824: (new Test("add172")).ok = ((new com.ibm.icu.math.BigDecimal(
01825: "12E+3")).add(new com.ibm.icu.math.BigDecimal("3456"),
01826: mc3).toString()).equals("1.55E+4");
01827: // next was 1.54E+4 under old [truncate to digits+1] rules
01828: (new Test("add173")).ok = ((new com.ibm.icu.math.BigDecimal(
01829: "12E+3")).add(new com.ibm.icu.math.BigDecimal("3446"),
01830: mc3).toString()).equals("1.55E+4");
01831: (new Test("add174")).ok = ((new com.ibm.icu.math.BigDecimal(
01832: "12E+3")).add(new com.ibm.icu.math.BigDecimal("3454"),
01833: mc3).toString()).equals("1.55E+4");
01834: (new Test("add175")).ok = ((new com.ibm.icu.math.BigDecimal(
01835: "12E+3")).add(new com.ibm.icu.math.BigDecimal("3444"),
01836: mc3).toString()).equals("1.54E+4");
01837:
01838: (new Test("add176")).ok = ((new com.ibm.icu.math.BigDecimal(
01839: "3456")).add(new com.ibm.icu.math.BigDecimal("12E+3"),
01840: mc3).toString()).equals("1.55E+4");
01841: // next was 1.54E+4 under old [truncate to digits+1] rules
01842: (new Test("add177")).ok = ((new com.ibm.icu.math.BigDecimal(
01843: "3446")).add(new com.ibm.icu.math.BigDecimal("12E+3"),
01844: mc3).toString()).equals("1.55E+4");
01845: (new Test("add178")).ok = ((new com.ibm.icu.math.BigDecimal(
01846: "3454")).add(new com.ibm.icu.math.BigDecimal("12E+3"),
01847: mc3).toString()).equals("1.55E+4");
01848: (new Test("add179")).ok = ((new com.ibm.icu.math.BigDecimal(
01849: "3444")).add(new com.ibm.icu.math.BigDecimal("12E+3"),
01850: mc3).toString()).equals("1.54E+4");
01851:
01852: try {
01853: checknull: do {
01854: ten.add((com.ibm.icu.math.BigDecimal) null);
01855: flag = false;
01856: } while (false);
01857: } catch (java.lang.NullPointerException $22) {
01858: flag = true;
01859: }/*checknull*/
01860: (new Test("add200")).ok = flag;
01861: try {
01862: checknull2: do {
01863: ten.add(ten, (com.ibm.icu.math.MathContext) null);
01864: flag = false;
01865: } while (false);
01866: } catch (java.lang.NullPointerException $23) {
01867: flag = true;
01868: }/*checknull2*/
01869: (new Test("add201")).ok = flag;
01870:
01871: try {
01872: checkdigits: do {
01873: tenlong.add(com.ibm.icu.math.BigDecimal.ZERO, mcld);
01874: flag = false;
01875: } while (false);
01876: } catch (java.lang.ArithmeticException $24) {
01877: ae = $24;
01878: flag = (ae.getMessage()).equals("Too many digits:" + " "
01879: + tenlong.toString());
01880: }/*checkdigits*/
01881: (new Test("add202")).ok = flag;
01882: try {
01883: checkdigits: do {
01884: com.ibm.icu.math.BigDecimal.ZERO.add(tenlong, mcld);
01885: flag = false;
01886: } while (false);
01887: } catch (java.lang.ArithmeticException $25) {
01888: ae = $25;
01889: flag = (ae.getMessage()).equals("Too many digits:" + " "
01890: + tenlong.toString());
01891: }/*checkdigits*/
01892: (new Test("add203")).ok = flag;
01893:
01894: // check lostdigits not raised if digits=0 [dyadic method]
01895: try {
01896: checkdigits: do {
01897: tenlong.add(com.ibm.icu.math.BigDecimal.ZERO, mcld0);
01898: flag = true;
01899: } while (false);
01900: } catch (java.lang.ArithmeticException $26) {
01901: ae = $26;
01902: flag = false;
01903: }/*checkdigits*/
01904: (new Test("add204")).ok = flag;
01905: try {
01906: checkdigits: do {
01907: com.ibm.icu.math.BigDecimal.ZERO.add(tenlong, mcld0);
01908: flag = true;
01909: } while (false);
01910: } catch (java.lang.ArithmeticException $27) {
01911: ae = $27;
01912: flag = false;
01913: }/*checkdigits*/
01914: (new Test("add205")).ok = flag;
01915:
01916: summary("add");
01917: }
01918:
01919: /* ----------------------------------------------------------------- */
01920: /** Test the {@link com.ibm.icu.math.BigDecimal#compareTo(BigDecimal)} method. */
01921:
01922: public void diagcompareto() {
01923: boolean flag = false;
01924: java.lang.ArithmeticException ae = null;
01925: // we assume add/subtract test function; this just
01926: // tests existence, exceptions, and possible results
01927:
01928: (new Test("cpt001")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
01929: .compareTo(new com.ibm.icu.math.BigDecimal("2"))) == 1;
01930: (new Test("cpt002")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
01931: .compareTo(new com.ibm.icu.math.BigDecimal("5"))) == 0;
01932: (new Test("cpt003")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
01933: .compareTo(new com.ibm.icu.math.BigDecimal("5.00"))) == 0;
01934: (new Test("cpt004")).ok = ((new com.ibm.icu.math.BigDecimal(
01935: "0.5"))
01936: .compareTo(new com.ibm.icu.math.BigDecimal("0.5"))) == 0;
01937: (new Test("cpt005")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
01938: .compareTo(new com.ibm.icu.math.BigDecimal("5"))) == (-1);
01939: (new Test("cpt006")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
01940: .compareTo(new com.ibm.icu.math.BigDecimal("5"), mcdef)) == (-1);
01941: (new Test("cpt007")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
01942: .compareTo(new com.ibm.icu.math.BigDecimal("5"), mc6)) == (-1);
01943: (new Test("cpt008")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
01944: .compareTo(new com.ibm.icu.math.BigDecimal("5"), mcfd)) == (-1);
01945: try {
01946: checknull: do {
01947: ten.compareTo((com.ibm.icu.math.BigDecimal) null);
01948: flag = false;
01949: } while (false);
01950: } catch (java.lang.NullPointerException $28) {
01951: flag = true;
01952: }/*checknull*/
01953: (new Test("cpt100")).ok = flag;
01954: try {
01955: checknull2: do {
01956: ten.compareTo(ten, (com.ibm.icu.math.MathContext) null);
01957: flag = false;
01958: } while (false);
01959: } catch (java.lang.NullPointerException $29) {
01960: flag = true;
01961: }/*checknull2*/
01962: (new Test("cpt101")).ok = flag;
01963:
01964: try {
01965: checkdigits: do {
01966: tenlong
01967: .compareTo(com.ibm.icu.math.BigDecimal.ONE,
01968: mcld);
01969: flag = false;
01970: } while (false);
01971: } catch (java.lang.ArithmeticException $30) {
01972: ae = $30;
01973: flag = (ae.getMessage()).equals("Too many digits:" + " "
01974: + tenlong.toString());
01975: }/*checkdigits*/
01976: (new Test("cpt102")).ok = flag;
01977: try {
01978: checkdigits: do {
01979: com.ibm.icu.math.BigDecimal.ONE
01980: .compareTo(tenlong, mcld);
01981: flag = false;
01982: } while (false);
01983: } catch (java.lang.ArithmeticException $31) {
01984: ae = $31;
01985: flag = (ae.getMessage()).equals("Too many digits:" + " "
01986: + tenlong.toString());
01987: }/*checkdigits*/
01988: (new Test("cpt103")).ok = flag;
01989:
01990: summary("compareTo");
01991: }
01992:
01993: /* ----------------------------------------------------------------- */
01994:
01995: /** Test the {@link com.ibm.icu.math.BigDecimal#divide} method. */
01996:
01997: public void diagdivide() {
01998: boolean flag = false;
01999: com.ibm.icu.math.MathContext rmcd;
02000: int rhu;
02001: int rd;
02002: int ru;
02003: java.lang.RuntimeException e = null;
02004: java.lang.ArithmeticException ae = null;
02005:
02006: (new Test("div301")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
02007: .divide(new com.ibm.icu.math.BigDecimal("3"), mcdef)
02008: .toString()).equals("0.333333333");
02009: (new Test("div302")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
02010: .divide(new com.ibm.icu.math.BigDecimal("3"), mcdef)
02011: .toString()).equals("0.666666667");
02012: (new Test("div303")).ok = ((new com.ibm.icu.math.BigDecimal(
02013: "2.4")).divide(new com.ibm.icu.math.BigDecimal("1"),
02014: mcdef).toString()).equals("2.4");
02015: (new Test("div304")).ok = ((new com.ibm.icu.math.BigDecimal(
02016: "2.4")).divide(new com.ibm.icu.math.BigDecimal("-1"),
02017: mcdef).toString()).equals("-2.4");
02018: (new Test("div305")).ok = ((new com.ibm.icu.math.BigDecimal(
02019: "-2.4")).divide(new com.ibm.icu.math.BigDecimal("1"),
02020: mcdef).toString()).equals("-2.4");
02021: (new Test("div306")).ok = ((new com.ibm.icu.math.BigDecimal(
02022: "-2.4")).divide(new com.ibm.icu.math.BigDecimal("-1"),
02023: mcdef).toString()).equals("2.4");
02024: (new Test("div307")).ok = ((new com.ibm.icu.math.BigDecimal(
02025: "2.40")).divide(new com.ibm.icu.math.BigDecimal("1"),
02026: mcdef).toString()).equals("2.4");
02027: (new Test("div308")).ok = ((new com.ibm.icu.math.BigDecimal(
02028: "2.400")).divide(new com.ibm.icu.math.BigDecimal("1"),
02029: mcdef).toString()).equals("2.4");
02030: (new Test("div309")).ok = ((new com.ibm.icu.math.BigDecimal(
02031: "2.4")).divide(new com.ibm.icu.math.BigDecimal("2"),
02032: mcdef).toString()).equals("1.2");
02033: (new Test("div310")).ok = ((new com.ibm.icu.math.BigDecimal(
02034: "2.400")).divide(new com.ibm.icu.math.BigDecimal("2"),
02035: mcdef).toString()).equals("1.2");
02036: (new Test("div311")).ok = ((new com.ibm.icu.math.BigDecimal(
02037: "2.")).divide(new com.ibm.icu.math.BigDecimal("2"),
02038: mcdef).toString()).equals("1");
02039: (new Test("div312")).ok = ((new com.ibm.icu.math.BigDecimal(
02040: "20")).divide(new com.ibm.icu.math.BigDecimal("20"),
02041: mcdef).toString()).equals("1");
02042: (new Test("div313")).ok = ((new com.ibm.icu.math.BigDecimal(
02043: "187")).divide(new com.ibm.icu.math.BigDecimal("187"),
02044: mcdef).toString()).equals("1");
02045: (new Test("div314")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
02046: .divide(new com.ibm.icu.math.BigDecimal("2"), mcdef)
02047: .toString()).equals("2.5");
02048: (new Test("div315")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
02049: .divide(new com.ibm.icu.math.BigDecimal("2.0"), mcdef)
02050: .toString()).equals("2.5");
02051: (new Test("div316")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
02052: .divide(new com.ibm.icu.math.BigDecimal("2.000"), mcdef)
02053: .toString()).equals("2.5");
02054: (new Test("div317")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
02055: .divide(new com.ibm.icu.math.BigDecimal("0.200"), mcdef)
02056: .toString()).equals("25");
02057: (new Test("div318")).ok = ((new com.ibm.icu.math.BigDecimal(
02058: "999999999")).divide(new com.ibm.icu.math.BigDecimal(
02059: "1"), mcdef).toString()).equals("999999999");
02060: (new Test("div319")).ok = ((new com.ibm.icu.math.BigDecimal(
02061: "999999999.4")).divide(new com.ibm.icu.math.BigDecimal(
02062: "1"), mcdef).toString()).equals("999999999");
02063: (new Test("div320")).ok = ((new com.ibm.icu.math.BigDecimal(
02064: "999999999.5")).divide(new com.ibm.icu.math.BigDecimal(
02065: "1"), mcdef).toString()).equals("1E+9");
02066: (new Test("div321")).ok = ((new com.ibm.icu.math.BigDecimal(
02067: "999999999.9")).divide(new com.ibm.icu.math.BigDecimal(
02068: "1"), mcdef).toString()).equals("1E+9");
02069: (new Test("div322")).ok = ((new com.ibm.icu.math.BigDecimal(
02070: "999999999.999")).divide(
02071: new com.ibm.icu.math.BigDecimal("1"), mcdef).toString())
02072: .equals("1E+9");
02073: (new Test("div323")).ok = ((new com.ibm.icu.math.BigDecimal(
02074: "0.0000E-50")).divide(new com.ibm.icu.math.BigDecimal(
02075: "1"), mcdef).toString()).equals("0");
02076: // MC
02077: (new Test("div325")).ok = ((new com.ibm.icu.math.BigDecimal(
02078: "999999999")).divide(new com.ibm.icu.math.BigDecimal(
02079: "1"), mcdef).toString()).equals("999999999");
02080: (new Test("div326")).ok = ((new com.ibm.icu.math.BigDecimal(
02081: "999999999")).divide(new com.ibm.icu.math.BigDecimal(
02082: "1"), mc6).toString()).equals("1E+9");
02083: (new Test("div327")).ok = ((new com.ibm.icu.math.BigDecimal(
02084: "9999999")).divide(
02085: new com.ibm.icu.math.BigDecimal("1"), mc6).toString())
02086: .equals("1E+7");
02087: (new Test("div328")).ok = ((new com.ibm.icu.math.BigDecimal(
02088: "999999")).divide(new com.ibm.icu.math.BigDecimal("1"),
02089: mc6).toString()).equals("999999");
02090:
02091: // check rounding explicitly [note: digits+1 truncation]
02092: rmcd = new com.ibm.icu.math.MathContext(2,
02093: com.ibm.icu.math.MathContext.SCIENTIFIC, false,
02094: com.ibm.icu.math.MathContext.ROUND_CEILING);
02095: (new Test("div330")).ok = ((new com.ibm.icu.math.BigDecimal(
02096: "1.50")).divide(one, rmcd).toString()).equals("1.5");
02097: (new Test("div331")).ok = ((new com.ibm.icu.math.BigDecimal(
02098: "1.51")).divide(one, rmcd).toString()).equals("1.6");
02099: (new Test("div332")).ok = ((new com.ibm.icu.math.BigDecimal(
02100: "1.55")).divide(one, rmcd).toString()).equals("1.6");
02101: rmcd = new com.ibm.icu.math.MathContext(2,
02102: com.ibm.icu.math.MathContext.SCIENTIFIC, false,
02103: com.ibm.icu.math.MathContext.ROUND_DOWN);
02104: (new Test("div333")).ok = ((new com.ibm.icu.math.BigDecimal(
02105: "1.55")).divide(one, rmcd).toString()).equals("1.5");
02106: (new Test("div334")).ok = ((new com.ibm.icu.math.BigDecimal(
02107: "1.59")).divide(one, rmcd).toString()).equals("1.5");
02108: rmcd = new com.ibm.icu.math.MathContext(2,
02109: com.ibm.icu.math.MathContext.SCIENTIFIC, false,
02110: com.ibm.icu.math.MathContext.ROUND_FLOOR);
02111: (new Test("div335")).ok = ((new com.ibm.icu.math.BigDecimal(
02112: "1.55")).divide(one, rmcd).toString()).equals("1.5");
02113: (new Test("div336")).ok = ((new com.ibm.icu.math.BigDecimal(
02114: "1.59")).divide(one, rmcd).toString()).equals("1.5");
02115: rmcd = new com.ibm.icu.math.MathContext(2,
02116: com.ibm.icu.math.MathContext.SCIENTIFIC, false,
02117: com.ibm.icu.math.MathContext.ROUND_HALF_DOWN);
02118: (new Test("div337")).ok = ((new com.ibm.icu.math.BigDecimal(
02119: "1.45")).divide(one, rmcd).toString()).equals("1.4");
02120: (new Test("div338")).ok = ((new com.ibm.icu.math.BigDecimal(
02121: "1.50")).divide(one, rmcd).toString()).equals("1.5");
02122: (new Test("div339")).ok = ((new com.ibm.icu.math.BigDecimal(
02123: "1.55")).divide(one, rmcd).toString()).equals("1.5");
02124: rmcd = new com.ibm.icu.math.MathContext(2,
02125: com.ibm.icu.math.MathContext.SCIENTIFIC, false,
02126: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN);
02127: (new Test("div340")).ok = ((new com.ibm.icu.math.BigDecimal(
02128: "1.45")).divide(one, rmcd).toString()).equals("1.4");
02129: (new Test("div341")).ok = ((new com.ibm.icu.math.BigDecimal(
02130: "1.50")).divide(one, rmcd).toString()).equals("1.5");
02131: (new Test("div342")).ok = ((new com.ibm.icu.math.BigDecimal(
02132: "1.55")).divide(one, rmcd).toString()).equals("1.6");
02133: rmcd = new com.ibm.icu.math.MathContext(2,
02134: com.ibm.icu.math.MathContext.SCIENTIFIC, false,
02135: com.ibm.icu.math.MathContext.ROUND_HALF_UP);
02136: (new Test("div343")).ok = ((new com.ibm.icu.math.BigDecimal(
02137: "1.45")).divide(one, rmcd).toString()).equals("1.5");
02138: (new Test("div344")).ok = ((new com.ibm.icu.math.BigDecimal(
02139: "1.50")).divide(one, rmcd).toString()).equals("1.5");
02140: (new Test("div345")).ok = ((new com.ibm.icu.math.BigDecimal(
02141: "1.55")).divide(one, rmcd).toString()).equals("1.6");
02142: rmcd = new com.ibm.icu.math.MathContext(2,
02143: com.ibm.icu.math.MathContext.SCIENTIFIC, false,
02144: com.ibm.icu.math.MathContext.ROUND_UP);
02145: (new Test("div346")).ok = ((new com.ibm.icu.math.BigDecimal(
02146: "1.50")).divide(one, rmcd).toString()).equals("1.5");
02147: (new Test("div347")).ok = ((new com.ibm.icu.math.BigDecimal(
02148: "1.51")).divide(one, rmcd).toString()).equals("1.6");
02149: (new Test("div348")).ok = ((new com.ibm.icu.math.BigDecimal(
02150: "1.55")).divide(one, rmcd).toString()).equals("1.6");
02151:
02152: // fixed point...
02153: (new Test("div350")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
02154: .divide(new com.ibm.icu.math.BigDecimal("3"))
02155: .toString()).equals("0");
02156: (new Test("div351")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
02157: .divide(new com.ibm.icu.math.BigDecimal("3"))
02158: .toString()).equals("1");
02159: (new Test("div352")).ok = ((new com.ibm.icu.math.BigDecimal(
02160: "2.4")).divide(new com.ibm.icu.math.BigDecimal("1"))
02161: .toString()).equals("2.4");
02162: (new Test("div353")).ok = ((new com.ibm.icu.math.BigDecimal(
02163: "2.4")).divide(new com.ibm.icu.math.BigDecimal("-1"))
02164: .toString()).equals("-2.4");
02165: (new Test("div354")).ok = ((new com.ibm.icu.math.BigDecimal(
02166: "-2.4")).divide(new com.ibm.icu.math.BigDecimal("1"))
02167: .toString()).equals("-2.4");
02168: (new Test("div355")).ok = ((new com.ibm.icu.math.BigDecimal(
02169: "-2.4")).divide(new com.ibm.icu.math.BigDecimal("-1"))
02170: .toString()).equals("2.4");
02171: (new Test("div356")).ok = ((new com.ibm.icu.math.BigDecimal(
02172: "2.40")).divide(new com.ibm.icu.math.BigDecimal("1"))
02173: .toString()).equals("2.40");
02174: (new Test("div357")).ok = ((new com.ibm.icu.math.BigDecimal(
02175: "2.400")).divide(new com.ibm.icu.math.BigDecimal("1"))
02176: .toString()).equals("2.400");
02177: (new Test("div358")).ok = ((new com.ibm.icu.math.BigDecimal(
02178: "2.4")).divide(new com.ibm.icu.math.BigDecimal("2"))
02179: .toString()).equals("1.2");
02180: (new Test("div359")).ok = ((new com.ibm.icu.math.BigDecimal(
02181: "2.400")).divide(new com.ibm.icu.math.BigDecimal("2"))
02182: .toString()).equals("1.200");
02183: (new Test("div360")).ok = ((new com.ibm.icu.math.BigDecimal(
02184: "2.")).divide(new com.ibm.icu.math.BigDecimal("2"))
02185: .toString()).equals("1");
02186: (new Test("div361")).ok = ((new com.ibm.icu.math.BigDecimal(
02187: "20")).divide(new com.ibm.icu.math.BigDecimal("20"))
02188: .toString()).equals("1");
02189: (new Test("div362")).ok = ((new com.ibm.icu.math.BigDecimal(
02190: "187")).divide(new com.ibm.icu.math.BigDecimal("187"))
02191: .toString()).equals("1");
02192: (new Test("div363")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
02193: .divide(new com.ibm.icu.math.BigDecimal("2"))
02194: .toString()).equals("3");
02195: (new Test("div364")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
02196: .divide(new com.ibm.icu.math.BigDecimal("2.0"))
02197: .toString()).equals("3");
02198: (new Test("div365")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
02199: .divide(new com.ibm.icu.math.BigDecimal("2.000"))
02200: .toString()).equals("3");
02201: (new Test("div366")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
02202: .divide(new com.ibm.icu.math.BigDecimal("0.200"))
02203: .toString()).equals("25");
02204: (new Test("div367")).ok = ((new com.ibm.icu.math.BigDecimal(
02205: "5.0")).divide(new com.ibm.icu.math.BigDecimal("2"))
02206: .toString()).equals("2.5");
02207: (new Test("div368")).ok = ((new com.ibm.icu.math.BigDecimal(
02208: "5.0")).divide(new com.ibm.icu.math.BigDecimal("2.0"))
02209: .toString()).equals("2.5");
02210: (new Test("div369")).ok = ((new com.ibm.icu.math.BigDecimal(
02211: "5.0"))
02212: .divide(new com.ibm.icu.math.BigDecimal("2.000"))
02213: .toString()).equals("2.5");
02214: (new Test("div370")).ok = ((new com.ibm.icu.math.BigDecimal(
02215: "5.0"))
02216: .divide(new com.ibm.icu.math.BigDecimal("0.200"))
02217: .toString()).equals("25.0");
02218: (new Test("div371")).ok = ((new com.ibm.icu.math.BigDecimal(
02219: "999999999")).divide(new com.ibm.icu.math.BigDecimal(
02220: "1")).toString()).equals("999999999");
02221: (new Test("div372")).ok = ((new com.ibm.icu.math.BigDecimal(
02222: "999999999.4")).divide(new com.ibm.icu.math.BigDecimal(
02223: "1")).toString()).equals("999999999.4");
02224: (new Test("div373")).ok = ((new com.ibm.icu.math.BigDecimal(
02225: "999999999.5")).divide(new com.ibm.icu.math.BigDecimal(
02226: "1")).toString()).equals("999999999.5");
02227: (new Test("div374")).ok = ((new com.ibm.icu.math.BigDecimal(
02228: "999999999.9")).divide(new com.ibm.icu.math.BigDecimal(
02229: "1")).toString()).equals("999999999.9");
02230: (new Test("div375")).ok = ((new com.ibm.icu.math.BigDecimal(
02231: "999999999.999"))
02232: .divide(new com.ibm.icu.math.BigDecimal("1"))
02233: .toString()).equals("999999999.999");
02234: (new Test("div376")).ok = ((new com.ibm.icu.math.BigDecimal(
02235: "0.0000E-5")).divide(new com.ibm.icu.math.BigDecimal(
02236: "1")).toString()).equals("0");
02237: (new Test("div377")).ok = ((new com.ibm.icu.math.BigDecimal(
02238: "0.000000000")).divide(new com.ibm.icu.math.BigDecimal(
02239: "1")).toString()).equals("0.000000000");
02240:
02241: //- Fixed point; explicit scales & rounds [old BigDecimal divides]
02242: rhu = com.ibm.icu.math.MathContext.ROUND_HALF_UP;
02243: rd = com.ibm.icu.math.MathContext.ROUND_DOWN;
02244: (new Test("div001")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
02245: .divide(new com.ibm.icu.math.BigDecimal("3"))
02246: .toString()).equals("0");
02247: (new Test("div002")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
02248: .divide(new com.ibm.icu.math.BigDecimal("3"), rhu)
02249: .toString()).equals("0");
02250: (new Test("div003")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
02251: .divide(new com.ibm.icu.math.BigDecimal("3"), 0, rhu)
02252: .toString()).equals("0");
02253: (new Test("div004")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
02254: .divide(new com.ibm.icu.math.BigDecimal("3"), 1, rhu)
02255: .toString()).equals("0.0");
02256: (new Test("div005")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
02257: .divide(new com.ibm.icu.math.BigDecimal("3"), 2, rhu)
02258: .toString()).equals("0.00");
02259: (new Test("div006")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
02260: .divide(new com.ibm.icu.math.BigDecimal("3"), 3, rhu)
02261: .toString()).equals("0.000");
02262: (new Test("div007")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
02263: .divide(new com.ibm.icu.math.BigDecimal("3"), 4, rhu)
02264: .toString()).equals("0.0000");
02265: (new Test("div008")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
02266: .divide(new com.ibm.icu.math.BigDecimal("3"))
02267: .toString()).equals("0");
02268: (new Test("div009")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
02269: .divide(new com.ibm.icu.math.BigDecimal("3"), rhu)
02270: .toString()).equals("0");
02271: (new Test("div010")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
02272: .divide(new com.ibm.icu.math.BigDecimal("3"), 0, rhu)
02273: .toString()).equals("0");
02274: (new Test("div011")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
02275: .divide(new com.ibm.icu.math.BigDecimal("3"), 1, rhu)
02276: .toString()).equals("0.3");
02277: (new Test("div012")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
02278: .divide(new com.ibm.icu.math.BigDecimal("3"), 2, rhu)
02279: .toString()).equals("0.33");
02280: (new Test("div013")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
02281: .divide(new com.ibm.icu.math.BigDecimal("3"), 3, rhu)
02282: .toString()).equals("0.333");
02283: (new Test("div014")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
02284: .divide(new com.ibm.icu.math.BigDecimal("3"), 4, rhu)
02285: .toString()).equals("0.3333");
02286: (new Test("div015")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
02287: .divide(new com.ibm.icu.math.BigDecimal("3"))
02288: .toString()).equals("1");
02289: (new Test("div016")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
02290: .divide(new com.ibm.icu.math.BigDecimal("3"), rhu)
02291: .toString()).equals("1");
02292: (new Test("div017")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
02293: .divide(new com.ibm.icu.math.BigDecimal("3"), 0, rhu)
02294: .toString()).equals("1");
02295: (new Test("div018")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
02296: .divide(new com.ibm.icu.math.BigDecimal("3"), 1, rhu)
02297: .toString()).equals("0.7");
02298: (new Test("div019")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
02299: .divide(new com.ibm.icu.math.BigDecimal("3"), 2, rhu)
02300: .toString()).equals("0.67");
02301: (new Test("div020")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
02302: .divide(new com.ibm.icu.math.BigDecimal("3"), 3, rhu)
02303: .toString()).equals("0.667");
02304: (new Test("div021")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
02305: .divide(new com.ibm.icu.math.BigDecimal("3"), 4, rhu)
02306: .toString()).equals("0.6667");
02307:
02308: (new Test("div030")).ok = ((new com.ibm.icu.math.BigDecimal(
02309: "1000")).divide(
02310: new com.ibm.icu.math.BigDecimal("2000"), 4, rhu)
02311: .toString()).equals("0.5000");
02312: (new Test("div031")).ok = ((new com.ibm.icu.math.BigDecimal(
02313: "1000")).divide(
02314: new com.ibm.icu.math.BigDecimal("2000"), 3, rhu)
02315: .toString()).equals("0.500");
02316: (new Test("div032")).ok = ((new com.ibm.icu.math.BigDecimal(
02317: "1000")).divide(
02318: new com.ibm.icu.math.BigDecimal("2000"), 2, rhu)
02319: .toString()).equals("0.50");
02320: (new Test("div033")).ok = ((new com.ibm.icu.math.BigDecimal(
02321: "1000")).divide(
02322: new com.ibm.icu.math.BigDecimal("2000"), 1, rhu)
02323: .toString()).equals("0.5");
02324: (new Test("div034")).ok = ((new com.ibm.icu.math.BigDecimal(
02325: "1000")).divide(
02326: new com.ibm.icu.math.BigDecimal("2000"), 0, rhu)
02327: .toString()).equals("1");
02328:
02329: (new Test("div035")).ok = ((new com.ibm.icu.math.BigDecimal(
02330: "100")).divide(new com.ibm.icu.math.BigDecimal("5000"),
02331: 4, rhu).toString()).equals("0.0200");
02332: (new Test("div036")).ok = ((new com.ibm.icu.math.BigDecimal(
02333: "100")).divide(new com.ibm.icu.math.BigDecimal("5000"),
02334: 3, rhu).toString()).equals("0.020");
02335: (new Test("div037")).ok = ((new com.ibm.icu.math.BigDecimal(
02336: "100")).divide(new com.ibm.icu.math.BigDecimal("5000"),
02337: 2, rhu).toString()).equals("0.02");
02338: (new Test("div038")).ok = ((new com.ibm.icu.math.BigDecimal(
02339: "100")).divide(new com.ibm.icu.math.BigDecimal("5000"),
02340: 1, rhu).toString()).equals("0.0");
02341: (new Test("div039")).ok = ((new com.ibm.icu.math.BigDecimal(
02342: "100")).divide(new com.ibm.icu.math.BigDecimal("5000"),
02343: 0, rhu).toString()).equals("0");
02344:
02345: (new Test("div040")).ok = ((new com.ibm.icu.math.BigDecimal(
02346: "9.99999999")).divide(new com.ibm.icu.math.BigDecimal(
02347: "9.77777777"), 4, rhu).toString()).equals("1.0227");
02348: (new Test("div041")).ok = ((new com.ibm.icu.math.BigDecimal(
02349: "9.9999999")).divide(new com.ibm.icu.math.BigDecimal(
02350: "9.7777777"), 4, rhu).toString()).equals("1.0227");
02351: (new Test("div042")).ok = ((new com.ibm.icu.math.BigDecimal(
02352: "9.999999")).divide(new com.ibm.icu.math.BigDecimal(
02353: "9.777777"), 4, rhu).toString()).equals("1.0227");
02354: (new Test("div043")).ok = ((new com.ibm.icu.math.BigDecimal(
02355: "9.77777777")).divide(new com.ibm.icu.math.BigDecimal(
02356: "9.99999999"), 4, rhu).toString()).equals("0.9778");
02357: (new Test("div044")).ok = ((new com.ibm.icu.math.BigDecimal(
02358: "9.7777777")).divide(new com.ibm.icu.math.BigDecimal(
02359: "9.9999999"), 4, rhu).toString()).equals("0.9778");
02360: (new Test("div045")).ok = ((new com.ibm.icu.math.BigDecimal(
02361: "9.777777")).divide(new com.ibm.icu.math.BigDecimal(
02362: "9.999999"), 4, rhu).toString()).equals("0.9778");
02363: (new Test("div046")).ok = ((new com.ibm.icu.math.BigDecimal(
02364: "9.77777")).divide(new com.ibm.icu.math.BigDecimal(
02365: "9.99999"), 4, rhu).toString()).equals("0.9778");
02366: (new Test("div047")).ok = ((new com.ibm.icu.math.BigDecimal(
02367: "9.7777")).divide(new com.ibm.icu.math.BigDecimal(
02368: "9.9999"), 4, rhu).toString()).equals("0.9778");
02369: (new Test("div048")).ok = ((new com.ibm.icu.math.BigDecimal(
02370: "9.777")).divide(new com.ibm.icu.math.BigDecimal(
02371: "9.999"), 4, rhu).toString()).equals("0.9778");
02372: (new Test("div049")).ok = ((new com.ibm.icu.math.BigDecimal(
02373: "9.77")).divide(
02374: new com.ibm.icu.math.BigDecimal("9.99"), 4, rhu)
02375: .toString()).equals("0.9780");
02376: (new Test("div050")).ok = ((new com.ibm.icu.math.BigDecimal(
02377: "9.7")).divide(new com.ibm.icu.math.BigDecimal("9.9"),
02378: 4, rhu).toString()).equals("0.9798");
02379: (new Test("div051")).ok = ((new com.ibm.icu.math.BigDecimal(
02380: "9.")).divide(new com.ibm.icu.math.BigDecimal("9."), 4,
02381: rhu).toString()).equals("1.0000");
02382:
02383: (new Test("div060")).ok = ((new com.ibm.icu.math.BigDecimal(
02384: "9.99999999")).divide(new com.ibm.icu.math.BigDecimal(
02385: "9.77777777"), rhu).toString()).equals("1.02272727");
02386: (new Test("div061")).ok = ((new com.ibm.icu.math.BigDecimal(
02387: "9.9999999")).divide(new com.ibm.icu.math.BigDecimal(
02388: "9.7777777"), rhu).toString()).equals("1.0227273");
02389: (new Test("div062")).ok = ((new com.ibm.icu.math.BigDecimal(
02390: "9.999999")).divide(new com.ibm.icu.math.BigDecimal(
02391: "9.777777"), rhu).toString()).equals("1.022727");
02392: (new Test("div063")).ok = ((new com.ibm.icu.math.BigDecimal(
02393: "9.77777777")).divide(new com.ibm.icu.math.BigDecimal(
02394: "9.99999999"), rhu).toString()).equals("0.97777778");
02395: (new Test("div064")).ok = ((new com.ibm.icu.math.BigDecimal(
02396: "9.7777777")).divide(new com.ibm.icu.math.BigDecimal(
02397: "9.9999999"), rhu).toString()).equals("0.9777778");
02398: (new Test("div065")).ok = ((new com.ibm.icu.math.BigDecimal(
02399: "9.777777")).divide(new com.ibm.icu.math.BigDecimal(
02400: "9.999999"), rhu).toString()).equals("0.977778");
02401: (new Test("div066")).ok = ((new com.ibm.icu.math.BigDecimal(
02402: "9.77777")).divide(new com.ibm.icu.math.BigDecimal(
02403: "9.99999"), rhu).toString()).equals("0.97778");
02404: (new Test("div067")).ok = ((new com.ibm.icu.math.BigDecimal(
02405: "9.7777")).divide(new com.ibm.icu.math.BigDecimal(
02406: "9.9999"), rhu).toString()).equals("0.9778");
02407: (new Test("div068")).ok = ((new com.ibm.icu.math.BigDecimal(
02408: "9.777")).divide(new com.ibm.icu.math.BigDecimal(
02409: "9.999"), rhu).toString()).equals("0.978");
02410: (new Test("div069")).ok = ((new com.ibm.icu.math.BigDecimal(
02411: "9.77")).divide(
02412: new com.ibm.icu.math.BigDecimal("9.99"), rhu)
02413: .toString()).equals("0.98");
02414: (new Test("div070")).ok = ((new com.ibm.icu.math.BigDecimal(
02415: "9.7")).divide(new com.ibm.icu.math.BigDecimal("9.9"),
02416: rhu).toString()).equals("1.0");
02417: (new Test("div071")).ok = ((new com.ibm.icu.math.BigDecimal(
02418: "9.")).divide(new com.ibm.icu.math.BigDecimal("9."),
02419: rhu).toString()).equals("1");
02420:
02421: rd = com.ibm.icu.math.MathContext.ROUND_DOWN; // test this is actually being used
02422: (new Test("div080")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
02423: .divide(new com.ibm.icu.math.BigDecimal("3"), 0, rd)
02424: .toString()).equals("0");
02425: (new Test("div081")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
02426: .divide(new com.ibm.icu.math.BigDecimal("3"), 1, rd)
02427: .toString()).equals("0.6");
02428: (new Test("div082")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
02429: .divide(new com.ibm.icu.math.BigDecimal("3"), 2, rd)
02430: .toString()).equals("0.66");
02431: (new Test("div083")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
02432: .divide(new com.ibm.icu.math.BigDecimal("3"), 3, rd)
02433: .toString()).equals("0.666");
02434: (new Test("div084")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
02435: .divide(new com.ibm.icu.math.BigDecimal("3"), 4, rd)
02436: .toString()).equals("0.6666");
02437:
02438: ru = com.ibm.icu.math.MathContext.ROUND_UNNECESSARY; // check for some 0 residues
02439: (new Test("div090")).ok = ((new com.ibm.icu.math.BigDecimal(
02440: "1000")).divide(new com.ibm.icu.math.BigDecimal("5"),
02441: 4, ru).toString()).equals("200.0000");
02442: (new Test("div091")).ok = ((new com.ibm.icu.math.BigDecimal(
02443: "1000")).divide(new com.ibm.icu.math.BigDecimal("50"),
02444: 4, ru).toString()).equals("20.0000");
02445: (new Test("div092")).ok = ((new com.ibm.icu.math.BigDecimal(
02446: "1000")).divide(new com.ibm.icu.math.BigDecimal("500"),
02447: 4, ru).toString()).equals("2.0000");
02448: (new Test("div093")).ok = ((new com.ibm.icu.math.BigDecimal(
02449: "1000")).divide(
02450: new com.ibm.icu.math.BigDecimal("5000"), 4, ru)
02451: .toString()).equals("0.2000");
02452: (new Test("div094")).ok = ((new com.ibm.icu.math.BigDecimal(
02453: "1000")).divide(
02454: new com.ibm.icu.math.BigDecimal("5000"), 3, ru)
02455: .toString()).equals("0.200");
02456: (new Test("div095")).ok = ((new com.ibm.icu.math.BigDecimal(
02457: "1000")).divide(
02458: new com.ibm.icu.math.BigDecimal("5000"), 2, ru)
02459: .toString()).equals("0.20");
02460: (new Test("div096")).ok = ((new com.ibm.icu.math.BigDecimal(
02461: "1000")).divide(
02462: new com.ibm.icu.math.BigDecimal("5000"), 1, ru)
02463: .toString()).equals("0.2");
02464:
02465: // check rounding explicitly
02466: (new Test("div101")).ok = ((new com.ibm.icu.math.BigDecimal(
02467: "0.055")).divide(one, 2,
02468: com.ibm.icu.math.MathContext.ROUND_CEILING).toString())
02469: .equals("0.06");
02470: (new Test("div102")).ok = ((new com.ibm.icu.math.BigDecimal(
02471: "0.055")).divide(one, 1,
02472: com.ibm.icu.math.MathContext.ROUND_CEILING).toString())
02473: .equals("0.1");
02474: (new Test("div103")).ok = ((new com.ibm.icu.math.BigDecimal(
02475: "0.055")).divide(one, 0,
02476: com.ibm.icu.math.MathContext.ROUND_CEILING).toString())
02477: .equals("1");
02478: (new Test("div104")).ok = ((new com.ibm.icu.math.BigDecimal(
02479: "0.055")).divide(one, 2,
02480: com.ibm.icu.math.MathContext.ROUND_DOWN).toString())
02481: .equals("0.05");
02482: (new Test("div105")).ok = ((new com.ibm.icu.math.BigDecimal(
02483: "0.055")).divide(one, 1,
02484: com.ibm.icu.math.MathContext.ROUND_DOWN).toString())
02485: .equals("0.0");
02486: (new Test("div106")).ok = ((new com.ibm.icu.math.BigDecimal(
02487: "0.055")).divide(one, 0,
02488: com.ibm.icu.math.MathContext.ROUND_DOWN).toString())
02489: .equals("0");
02490: (new Test("div107")).ok = ((new com.ibm.icu.math.BigDecimal(
02491: "0.055")).divide(one, 2,
02492: com.ibm.icu.math.MathContext.ROUND_FLOOR).toString())
02493: .equals("0.05");
02494: (new Test("div108")).ok = ((new com.ibm.icu.math.BigDecimal(
02495: "0.055")).divide(one, 1,
02496: com.ibm.icu.math.MathContext.ROUND_FLOOR).toString())
02497: .equals("0.0");
02498: (new Test("div109")).ok = ((new com.ibm.icu.math.BigDecimal(
02499: "0.055")).divide(one, 0,
02500: com.ibm.icu.math.MathContext.ROUND_FLOOR).toString())
02501: .equals("0");
02502:
02503: (new Test("div110")).ok = ((new com.ibm.icu.math.BigDecimal(
02504: "0.045")).divide(one, 2,
02505: com.ibm.icu.math.MathContext.ROUND_HALF_DOWN)
02506: .toString()).equals("0.04");
02507: (new Test("div111")).ok = ((new com.ibm.icu.math.BigDecimal(
02508: "0.045")).divide(one, 1,
02509: com.ibm.icu.math.MathContext.ROUND_HALF_DOWN)
02510: .toString()).equals("0.0");
02511: (new Test("div112")).ok = ((new com.ibm.icu.math.BigDecimal(
02512: "0.045")).divide(one, 0,
02513: com.ibm.icu.math.MathContext.ROUND_HALF_DOWN)
02514: .toString()).equals("0");
02515: (new Test("div113")).ok = ((new com.ibm.icu.math.BigDecimal(
02516: "0.050")).divide(one, 2,
02517: com.ibm.icu.math.MathContext.ROUND_HALF_DOWN)
02518: .toString()).equals("0.05");
02519: (new Test("div114")).ok = ((new com.ibm.icu.math.BigDecimal(
02520: "0.050")).divide(one, 1,
02521: com.ibm.icu.math.MathContext.ROUND_HALF_DOWN)
02522: .toString()).equals("0.0");
02523: (new Test("div115")).ok = ((new com.ibm.icu.math.BigDecimal(
02524: "0.050")).divide(one, 0,
02525: com.ibm.icu.math.MathContext.ROUND_HALF_DOWN)
02526: .toString()).equals("0");
02527: (new Test("div116")).ok = ((new com.ibm.icu.math.BigDecimal(
02528: "0.055")).divide(one, 2,
02529: com.ibm.icu.math.MathContext.ROUND_HALF_DOWN)
02530: .toString()).equals("0.05");
02531: (new Test("div117")).ok = ((new com.ibm.icu.math.BigDecimal(
02532: "0.055")).divide(one, 1,
02533: com.ibm.icu.math.MathContext.ROUND_HALF_DOWN)
02534: .toString()).equals("0.1");
02535: (new Test("div118")).ok = ((new com.ibm.icu.math.BigDecimal(
02536: "0.055")).divide(one, 0,
02537: com.ibm.icu.math.MathContext.ROUND_HALF_DOWN)
02538: .toString()).equals("0");
02539:
02540: (new Test("div120")).ok = ((new com.ibm.icu.math.BigDecimal(
02541: "0.045")).divide(one, 2,
02542: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN)
02543: .toString()).equals("0.04");
02544: (new Test("div121")).ok = ((new com.ibm.icu.math.BigDecimal(
02545: "0.045")).divide(one, 1,
02546: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN)
02547: .toString()).equals("0.0");
02548: (new Test("div122")).ok = ((new com.ibm.icu.math.BigDecimal(
02549: "0.045")).divide(one, 0,
02550: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN)
02551: .toString()).equals("0");
02552: (new Test("div123")).ok = ((new com.ibm.icu.math.BigDecimal(
02553: "0.050")).divide(one, 2,
02554: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN)
02555: .toString()).equals("0.05");
02556: (new Test("div124")).ok = ((new com.ibm.icu.math.BigDecimal(
02557: "0.050")).divide(one, 1,
02558: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN)
02559: .toString()).equals("0.0");
02560: (new Test("div125")).ok = ((new com.ibm.icu.math.BigDecimal(
02561: "0.050")).divide(one, 0,
02562: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN)
02563: .toString()).equals("0");
02564: (new Test("div126")).ok = ((new com.ibm.icu.math.BigDecimal(
02565: "0.150")).divide(one, 2,
02566: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN)
02567: .toString()).equals("0.15");
02568: (new Test("div127")).ok = ((new com.ibm.icu.math.BigDecimal(
02569: "0.150")).divide(one, 1,
02570: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN)
02571: .toString()).equals("0.2");
02572: (new Test("div128")).ok = ((new com.ibm.icu.math.BigDecimal(
02573: "0.150")).divide(one, 0,
02574: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN)
02575: .toString()).equals("0");
02576: (new Test("div129")).ok = ((new com.ibm.icu.math.BigDecimal(
02577: "0.055")).divide(one, 2,
02578: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN)
02579: .toString()).equals("0.06");
02580: (new Test("div130")).ok = ((new com.ibm.icu.math.BigDecimal(
02581: "0.055")).divide(one, 1,
02582: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN)
02583: .toString()).equals("0.1");
02584: (new Test("div131")).ok = ((new com.ibm.icu.math.BigDecimal(
02585: "0.055")).divide(one, 0,
02586: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN)
02587: .toString()).equals("0");
02588:
02589: (new Test("div140")).ok = ((new com.ibm.icu.math.BigDecimal(
02590: "0.045")).divide(one, 2,
02591: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
02592: .equals("0.05");
02593: (new Test("div141")).ok = ((new com.ibm.icu.math.BigDecimal(
02594: "0.045")).divide(one, 1,
02595: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
02596: .equals("0.0");
02597: (new Test("div142")).ok = ((new com.ibm.icu.math.BigDecimal(
02598: "0.045")).divide(one, 0,
02599: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
02600: .equals("0");
02601: (new Test("div143")).ok = ((new com.ibm.icu.math.BigDecimal(
02602: "0.050")).divide(one, 2,
02603: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
02604: .equals("0.05");
02605: (new Test("div144")).ok = ((new com.ibm.icu.math.BigDecimal(
02606: "0.050")).divide(one, 1,
02607: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
02608: .equals("0.1");
02609: (new Test("div145")).ok = ((new com.ibm.icu.math.BigDecimal(
02610: "0.050")).divide(one, 0,
02611: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
02612: .equals("0");
02613: (new Test("div146")).ok = ((new com.ibm.icu.math.BigDecimal(
02614: "0.055")).divide(one, 2,
02615: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
02616: .equals("0.06");
02617: (new Test("div147")).ok = ((new com.ibm.icu.math.BigDecimal(
02618: "0.055")).divide(one, 1,
02619: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
02620: .equals("0.1");
02621: (new Test("div148")).ok = ((new com.ibm.icu.math.BigDecimal(
02622: "0.055")).divide(one, 0,
02623: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
02624: .equals("0");
02625:
02626: (new Test("div150")).ok = ((new com.ibm.icu.math.BigDecimal(
02627: "0.055")).divide(one, 2,
02628: com.ibm.icu.math.MathContext.ROUND_UP).toString())
02629: .equals("0.06");
02630: (new Test("div151")).ok = ((new com.ibm.icu.math.BigDecimal(
02631: "0.055")).divide(one, 1,
02632: com.ibm.icu.math.MathContext.ROUND_UP).toString())
02633: .equals("0.1");
02634: (new Test("div52.")).ok = ((new com.ibm.icu.math.BigDecimal(
02635: "0.055")).divide(one, 0,
02636: com.ibm.icu.math.MathContext.ROUND_UP).toString())
02637: .equals("1");
02638:
02639: //- error conditions ---
02640: try {
02641: checknull: do {
02642: ten.divide((com.ibm.icu.math.BigDecimal) null);
02643: flag = false;
02644: } while (false);
02645: } catch (java.lang.NullPointerException $32) {
02646: flag = true;
02647: }/*checknull*/
02648: (new Test("div201")).ok = flag;
02649: try {
02650: checknull2: do {
02651: ten.divide(ten, (com.ibm.icu.math.MathContext) null);
02652: flag = false;
02653: } while (false);
02654: } catch (java.lang.NullPointerException $33) {
02655: flag = true;
02656: }/*checknull2*/
02657: (new Test("div202")).ok = flag;
02658:
02659: try {
02660: checkscale: do {
02661: (new com.ibm.icu.math.BigDecimal("1")).divide(
02662: new com.ibm.icu.math.BigDecimal("3"), -8, 0);
02663: flag = false;
02664: } while (false);
02665: } catch (java.lang.RuntimeException $34) {
02666: e = $34;
02667: flag = flag & (e.getMessage()).equals("Negative scale: -8");
02668: }/*checkscale*/
02669: (new Test("div203")).ok = flag;
02670:
02671: try {
02672: rounn: do {
02673: (new com.ibm.icu.math.BigDecimal("1000")).divide(
02674: new com.ibm.icu.math.BigDecimal("5000"), 0,
02675: com.ibm.icu.math.MathContext.ROUND_UNNECESSARY);
02676: flag = false;
02677: } while (false);
02678: } catch (java.lang.ArithmeticException $35) {
02679: ae = $35;
02680: flag = (ae.getMessage()).equals("Rounding necessary");
02681: }/*rounn*/
02682: (new Test("div204")).ok = flag;
02683: try {
02684: rounn: do {
02685: (new com.ibm.icu.math.BigDecimal("1001")).divide(
02686: new com.ibm.icu.math.BigDecimal("10"), 0,
02687: com.ibm.icu.math.MathContext.ROUND_UNNECESSARY);
02688: flag = false;
02689: } while (false);
02690: } catch (java.lang.ArithmeticException $36) {
02691: ae = $36;
02692: flag = (ae.getMessage()).equals("Rounding necessary");
02693: }/*rounn*/
02694: (new Test("div205")).ok = flag;
02695: try {
02696: rounn: do {
02697: (new com.ibm.icu.math.BigDecimal("1001")).divide(
02698: new com.ibm.icu.math.BigDecimal("100"), 1,
02699: com.ibm.icu.math.MathContext.ROUND_UNNECESSARY);
02700: flag = false;
02701: } while (false);
02702: } catch (java.lang.ArithmeticException $37) {
02703: ae = $37;
02704: flag = (ae.getMessage()).equals("Rounding necessary");
02705: }/*rounn*/
02706: (new Test("div206")).ok = flag;
02707: try {
02708: rounn: do {
02709: (new com.ibm.icu.math.BigDecimal("10001")).divide(
02710: new com.ibm.icu.math.BigDecimal("10000"), 1,
02711: com.ibm.icu.math.MathContext.ROUND_UNNECESSARY);
02712: flag = false;
02713: } while (false);
02714: } catch (java.lang.ArithmeticException $38) {
02715: ae = $38;
02716: flag = (ae.getMessage()).equals("Rounding necessary");
02717: }/*rounn*/
02718: (new Test("div207")).ok = flag;
02719: try {
02720: rounn: do {
02721: (new com.ibm.icu.math.BigDecimal("1.0001")).divide(
02722: new com.ibm.icu.math.BigDecimal("1"), 1,
02723: com.ibm.icu.math.MathContext.ROUND_UNNECESSARY);
02724: flag = false;
02725: } while (false);
02726: } catch (java.lang.ArithmeticException $39) {
02727: ae = $39;
02728: flag = (ae.getMessage()).equals("Rounding necessary");
02729: }/*rounn*/
02730: (new Test("div208")).ok = flag;
02731:
02732: try {
02733: div0: do {
02734: (new com.ibm.icu.math.BigDecimal("5"))
02735: .divide(new com.ibm.icu.math.BigDecimal("0.00"));
02736: flag = false;
02737: } while (false);
02738: } catch (java.lang.ArithmeticException $40) {
02739: ae = $40;
02740: flag = (ae.getMessage()).equals("Divide by 0");
02741: }/*div0*/
02742: (new Test("div209")).ok = flag;
02743:
02744: try {
02745: checkdigits: do {
02746: tenlong.divide(com.ibm.icu.math.BigDecimal.ONE, mcld);
02747: flag = false;
02748: } while (false);
02749: } catch (java.lang.ArithmeticException $41) {
02750: ae = $41;
02751: flag = (ae.getMessage()).equals("Too many digits:" + " "
02752: + tenlong.toString());
02753: }/*checkdigits*/
02754: (new Test("div210")).ok = flag;
02755: try {
02756: checkdigits: do {
02757: com.ibm.icu.math.BigDecimal.ONE.divide(tenlong, mcld);
02758: flag = false;
02759: } while (false);
02760: } catch (java.lang.ArithmeticException $42) {
02761: ae = $42;
02762: flag = (ae.getMessage()).equals("Too many digits:" + " "
02763: + tenlong.toString());
02764: }/*checkdigits*/
02765: (new Test("div211")).ok = flag;
02766:
02767: summary("divide");
02768: }
02769:
02770: /* ----------------------------------------------------------------- */
02771:
02772: /** Test the {@link com.ibm.icu.math.BigDecimal#divideInteger} method. */
02773:
02774: public void diagdivideInteger() {
02775: boolean flag = false;
02776: java.lang.ArithmeticException ae = null;
02777:
02778: (new Test("dvI001")).ok = ((new com.ibm.icu.math.BigDecimal(
02779: "101.3")).divideInteger(
02780: new com.ibm.icu.math.BigDecimal("1"), mcdef).toString())
02781: .equals("101");
02782: (new Test("dvI002")).ok = ((new com.ibm.icu.math.BigDecimal(
02783: "101.0")).divideInteger(
02784: new com.ibm.icu.math.BigDecimal("1"), mcdef).toString())
02785: .equals("101");
02786: (new Test("dvI003")).ok = ((new com.ibm.icu.math.BigDecimal(
02787: "101.3")).divideInteger(
02788: new com.ibm.icu.math.BigDecimal("3"), mcdef).toString())
02789: .equals("33");
02790: (new Test("dvI004")).ok = ((new com.ibm.icu.math.BigDecimal(
02791: "101.0")).divideInteger(
02792: new com.ibm.icu.math.BigDecimal("3"), mcdef).toString())
02793: .equals("33");
02794: (new Test("dvI005")).ok = ((new com.ibm.icu.math.BigDecimal(
02795: "2.4")).divideInteger(new com.ibm.icu.math.BigDecimal(
02796: "1"), mcdef).toString()).equals("2");
02797: (new Test("dvI006")).ok = ((new com.ibm.icu.math.BigDecimal(
02798: "2.400")).divideInteger(
02799: new com.ibm.icu.math.BigDecimal("1"), mcdef).toString())
02800: .equals("2");
02801: (new Test("dvI007")).ok = ((new com.ibm.icu.math.BigDecimal(
02802: "18")).divideInteger(new com.ibm.icu.math.BigDecimal(
02803: "18"), mcdef).toString()).equals("1");
02804: (new Test("dvI008")).ok = ((new com.ibm.icu.math.BigDecimal(
02805: "1120")).divideInteger(new com.ibm.icu.math.BigDecimal(
02806: "1000"), mcdef).toString()).equals("1");
02807: (new Test("dvI009")).ok = ((new com.ibm.icu.math.BigDecimal(
02808: "2.4")).divideInteger(new com.ibm.icu.math.BigDecimal(
02809: "2"), mcdef).toString()).equals("1");
02810: (new Test("dvI010")).ok = ((new com.ibm.icu.math.BigDecimal(
02811: "2.400")).divideInteger(
02812: new com.ibm.icu.math.BigDecimal("2"), mcdef).toString())
02813: .equals("1");
02814: (new Test("dvI011")).ok = ((new com.ibm.icu.math.BigDecimal(
02815: "0.5")).divideInteger(new com.ibm.icu.math.BigDecimal(
02816: "2.000"), mcdef).toString()).equals("0");
02817: (new Test("dvI012")).ok = ((new com.ibm.icu.math.BigDecimal(
02818: "8.005")).divideInteger(
02819: new com.ibm.icu.math.BigDecimal("7"), mcdef).toString())
02820: .equals("1");
02821: (new Test("dvI013")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
02822: .divideInteger(new com.ibm.icu.math.BigDecimal("2"),
02823: mcdef).toString()).equals("2");
02824: (new Test("dvI014")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
02825: .divideInteger(new com.ibm.icu.math.BigDecimal("2"),
02826: mcdef).toString()).equals("0");
02827: (new Test("dvI015")).ok = ((new com.ibm.icu.math.BigDecimal(
02828: "0.00")).divideInteger(new com.ibm.icu.math.BigDecimal(
02829: "2"), mcdef).toString()).equals("0");
02830: // MC
02831: (new Test("dvI016")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
02832: .divideInteger(new com.ibm.icu.math.BigDecimal("2"),
02833: mce).toString()).equals("2");
02834: (new Test("dvI017")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
02835: .divideInteger(new com.ibm.icu.math.BigDecimal("2"),
02836: mc6).toString()).equals("2");
02837:
02838: // Fixed --
02839: (new Test("dvI021")).ok = ((new com.ibm.icu.math.BigDecimal(
02840: "101.3"))
02841: .divideInteger(new com.ibm.icu.math.BigDecimal("1"))
02842: .toString()).equals("101");
02843: (new Test("dvI022")).ok = ((new com.ibm.icu.math.BigDecimal(
02844: "101.0"))
02845: .divideInteger(new com.ibm.icu.math.BigDecimal("1"))
02846: .toString()).equals("101");
02847: (new Test("dvI023")).ok = ((new com.ibm.icu.math.BigDecimal(
02848: "101.3"))
02849: .divideInteger(new com.ibm.icu.math.BigDecimal("3"))
02850: .toString()).equals("33");
02851: (new Test("dvI024")).ok = ((new com.ibm.icu.math.BigDecimal(
02852: "101.0"))
02853: .divideInteger(new com.ibm.icu.math.BigDecimal("3"))
02854: .toString()).equals("33");
02855: (new Test("dvI025")).ok = ((new com.ibm.icu.math.BigDecimal(
02856: "2.4")).divideInteger(new com.ibm.icu.math.BigDecimal(
02857: "1")).toString()).equals("2");
02858: (new Test("dvI026")).ok = ((new com.ibm.icu.math.BigDecimal(
02859: "2.400"))
02860: .divideInteger(new com.ibm.icu.math.BigDecimal("1"))
02861: .toString()).equals("2");
02862: (new Test("dvI027")).ok = ((new com.ibm.icu.math.BigDecimal(
02863: "18")).divideInteger(new com.ibm.icu.math.BigDecimal(
02864: "18")).toString()).equals("1");
02865: (new Test("dvI028")).ok = ((new com.ibm.icu.math.BigDecimal(
02866: "1120")).divideInteger(new com.ibm.icu.math.BigDecimal(
02867: "1000")).toString()).equals("1");
02868: (new Test("dvI029")).ok = ((new com.ibm.icu.math.BigDecimal(
02869: "2.4")).divideInteger(new com.ibm.icu.math.BigDecimal(
02870: "2")).toString()).equals("1");
02871: (new Test("dvI030")).ok = ((new com.ibm.icu.math.BigDecimal(
02872: "2.400"))
02873: .divideInteger(new com.ibm.icu.math.BigDecimal("2"))
02874: .toString()).equals("1");
02875: (new Test("dvI031")).ok = ((new com.ibm.icu.math.BigDecimal(
02876: "0.5")).divideInteger(new com.ibm.icu.math.BigDecimal(
02877: "2.000")).toString()).equals("0");
02878: (new Test("dvI032")).ok = ((new com.ibm.icu.math.BigDecimal(
02879: "8.005"))
02880: .divideInteger(new com.ibm.icu.math.BigDecimal("7"))
02881: .toString()).equals("1");
02882: (new Test("dvI033")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
02883: .divideInteger(new com.ibm.icu.math.BigDecimal("2"))
02884: .toString()).equals("2");
02885: (new Test("dvI034")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
02886: .divideInteger(new com.ibm.icu.math.BigDecimal("2"))
02887: .toString()).equals("0");
02888: (new Test("dvI035")).ok = ((new com.ibm.icu.math.BigDecimal(
02889: "0.00")).divideInteger(new com.ibm.icu.math.BigDecimal(
02890: "2")).toString()).equals("0");
02891:
02892: try {
02893: checknull: do {
02894: ten.divideInteger((com.ibm.icu.math.BigDecimal) null);
02895: flag = false;
02896: } while (false);
02897: } catch (java.lang.NullPointerException $43) {
02898: flag = true;
02899: }/*checknull*/
02900: (new Test("dvI101")).ok = flag;
02901: try {
02902: checknull2: do {
02903: ten.divideInteger(ten,
02904: (com.ibm.icu.math.MathContext) null);
02905: flag = false;
02906: } while (false);
02907: } catch (java.lang.NullPointerException $44) {
02908: flag = true;
02909: }/*checknull2*/
02910: (new Test("dvI102")).ok = flag;
02911:
02912: try {
02913: checkdigits: do {
02914: com.ibm.icu.math.BigDecimal.ONE.divideInteger(tenlong,
02915: mcld);
02916: flag = false;
02917: } while (false);
02918: } catch (java.lang.ArithmeticException $45) {
02919: ae = $45;
02920: flag = (ae.getMessage()).equals("Too many digits:" + " "
02921: + tenlong.toString());
02922: }/*checkdigits*/
02923: (new Test("dvI103")).ok = flag;
02924:
02925: try {
02926: checkdigits: do {
02927: tenlong.divideInteger(com.ibm.icu.math.BigDecimal.ONE,
02928: mcld);
02929: flag = false;
02930: } while (false);
02931: } catch (java.lang.ArithmeticException $46) {
02932: ae = $46;
02933: flag = (ae.getMessage()).equals("Too many digits:" + " "
02934: + tenlong.toString());
02935: }/*checkdigits*/
02936: (new Test("dvI104")).ok = flag;
02937:
02938: summary("divideInteger");
02939: }
02940:
02941: /* ----------------------------------------------------------------- */
02942:
02943: /** Test the {@link com.ibm.icu.math.BigDecimal#max} method. */
02944:
02945: public void diagmax() {
02946: boolean flag = false;
02947: java.lang.ArithmeticException ae = null;
02948:
02949: // we assume add/subtract test function; this and min just
02950: // test existence and test the truth table
02951: (new Test("max001")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
02952: .max(new com.ibm.icu.math.BigDecimal("2")).toString())
02953: .equals("5");
02954: (new Test("max002")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
02955: .max(new com.ibm.icu.math.BigDecimal("5")).toString())
02956: .equals("5");
02957: (new Test("max003")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
02958: .max(new com.ibm.icu.math.BigDecimal("7")).toString())
02959: .equals("7");
02960: (new Test("max004")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
02961: .max(new com.ibm.icu.math.BigDecimal("7"), mcdef)
02962: .toString()).equals("7");
02963: (new Test("max005")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
02964: .max(new com.ibm.icu.math.BigDecimal("7"), mc6)
02965: .toString()).equals("7");
02966: (new Test("max006")).ok = ((new com.ibm.icu.math.BigDecimal(
02967: "2E+3")).max(new com.ibm.icu.math.BigDecimal("7"))
02968: .toString()).equals("2000");
02969: (new Test("max007")).ok = ((new com.ibm.icu.math.BigDecimal(
02970: "2E+3")).max(new com.ibm.icu.math.BigDecimal("7"), mc3)
02971: .toString()).equals("2E+3");
02972: (new Test("max008")).ok = ((new com.ibm.icu.math.BigDecimal("7"))
02973: .max(new com.ibm.icu.math.BigDecimal("2E+3"))
02974: .toString()).equals("2000");
02975: (new Test("max009")).ok = ((new com.ibm.icu.math.BigDecimal("7"))
02976: .max(new com.ibm.icu.math.BigDecimal("2E+3"), mc3)
02977: .toString()).equals("2E+3");
02978: try {
02979: checknull: do {
02980: ten.max((com.ibm.icu.math.BigDecimal) null);
02981: flag = false;
02982: } while (false);
02983: } catch (java.lang.NullPointerException $47) {
02984: flag = true;
02985: }/*checknull*/
02986: (new Test("max010")).ok = flag;
02987: try {
02988: checknull2: do {
02989: ten.max(ten, (com.ibm.icu.math.MathContext) null);
02990: flag = false;
02991: } while (false);
02992: } catch (java.lang.NullPointerException $48) {
02993: flag = true;
02994: }/*checknull2*/
02995: (new Test("max011")).ok = flag;
02996: try {
02997: checkdigits: do {
02998: tenlong.max(com.ibm.icu.math.BigDecimal.ONE, mcld);
02999: flag = false;
03000: } while (false);
03001: } catch (java.lang.ArithmeticException $49) {
03002: ae = $49;
03003: flag = (ae.getMessage()).equals("Too many digits:" + " "
03004: + tenlong.toString());
03005: }/*checkdigits*/
03006: (new Test("max012")).ok = flag;
03007: try {
03008: checkdigits: do {
03009: com.ibm.icu.math.BigDecimal.ONE.max(tenlong, mcld);
03010: flag = false;
03011: } while (false);
03012: } catch (java.lang.ArithmeticException $50) {
03013: ae = $50;
03014: flag = (ae.getMessage()).equals("Too many digits:" + " "
03015: + tenlong.toString());
03016: }/*checkdigits*/
03017: (new Test("max013")).ok = flag;
03018: summary("max");
03019: }
03020:
03021: /** Test the {@link com.ibm.icu.math.BigDecimal#min} method. */
03022:
03023: public void diagmin() {
03024: boolean flag = false;
03025: com.ibm.icu.math.BigDecimal minx = null;
03026: java.lang.ArithmeticException ae = null;
03027: // we assume add/subtract test function; this and max just
03028: // test existence and test the truth table
03029:
03030: (new Test("min001")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
03031: .min(new com.ibm.icu.math.BigDecimal("2")).toString())
03032: .equals("2");
03033: (new Test("min002")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
03034: .min(new com.ibm.icu.math.BigDecimal("5")).toString())
03035: .equals("5");
03036: (new Test("min003")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
03037: .min(new com.ibm.icu.math.BigDecimal("7")).toString())
03038: .equals("2");
03039: (new Test("min004")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
03040: .min(new com.ibm.icu.math.BigDecimal("7"), mcdef)
03041: .toString()).equals("2");
03042: (new Test("min005")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
03043: .min(new com.ibm.icu.math.BigDecimal("7"), mc6)
03044: .toString()).equals("1");
03045: (new Test("min006")).ok = ((new com.ibm.icu.math.BigDecimal(
03046: "-2E+3")).min(new com.ibm.icu.math.BigDecimal("7"))
03047: .toString()).equals("-2000");
03048: (new Test("min007")).ok = ((new com.ibm.icu.math.BigDecimal(
03049: "-2E+3"))
03050: .min(new com.ibm.icu.math.BigDecimal("7"), mc3)
03051: .toString()).equals("-2E+3");
03052: (new Test("min008")).ok = ((new com.ibm.icu.math.BigDecimal("7"))
03053: .min(new com.ibm.icu.math.BigDecimal("-2E+3"))
03054: .toString()).equals("-2000");
03055: (new Test("min009")).ok = ((new com.ibm.icu.math.BigDecimal("7"))
03056: .min(new com.ibm.icu.math.BigDecimal("-2E+3"), mc3)
03057: .toString()).equals("-2E+3");
03058: try {
03059: checknull: do {
03060: minx = ten;
03061: minx.min((com.ibm.icu.math.BigDecimal) null);
03062: flag = false;
03063: } while (false);
03064: } catch (java.lang.NullPointerException $51) {
03065: flag = true;
03066: }/*checknull*/
03067: (new Test("min010")).ok = flag;
03068: try {
03069: checknull2: do {
03070: minx = ten;
03071: minx.min(ten, (com.ibm.icu.math.MathContext) null);
03072: flag = false;
03073: } while (false);
03074: } catch (java.lang.NullPointerException $52) {
03075: flag = true;
03076: }/*checknull2*/
03077: (new Test("min011")).ok = flag;
03078:
03079: try {
03080: checkdigits: do {
03081: tenlong.min(com.ibm.icu.math.BigDecimal.ONE, mcld);
03082: flag = false;
03083: } while (false);
03084: } catch (java.lang.ArithmeticException $53) {
03085: ae = $53;
03086: flag = (ae.getMessage()).equals("Too many digits:" + " "
03087: + tenlong.toString());
03088: }/*checkdigits*/
03089: (new Test("min012")).ok = flag;
03090: try {
03091: checkdigits: do {
03092: (new com.ibm.icu.math.BigDecimal(9)).min(tenlong, mcld);
03093: flag = false;
03094: } while (false);
03095: } catch (java.lang.ArithmeticException $54) {
03096: ae = $54;
03097: flag = (ae.getMessage()).equals("Too many digits:" + " "
03098: + tenlong.toString());
03099: }/*checkdigits*/
03100: (new Test("min013")).ok = flag;
03101: summary("min");
03102: }
03103:
03104: /* ----------------------------------------------------------------- */
03105:
03106: /** Test the {@link com.ibm.icu.math.BigDecimal#multiply} method. */
03107:
03108: public void diagmultiply() {
03109: boolean flag = false;
03110: com.ibm.icu.math.BigDecimal l9;
03111: com.ibm.icu.math.BigDecimal l77e;
03112: com.ibm.icu.math.BigDecimal l12345;
03113: com.ibm.icu.math.BigDecimal edge;
03114: com.ibm.icu.math.BigDecimal tenedge;
03115: com.ibm.icu.math.BigDecimal hunedge;
03116: com.ibm.icu.math.BigDecimal opo;
03117: com.ibm.icu.math.BigDecimal d1 = null;
03118: com.ibm.icu.math.BigDecimal d2 = null;
03119: java.lang.ArithmeticException oe = null;
03120: java.lang.ArithmeticException ae = null;
03121:
03122: (new Test("mul001")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
03123: .multiply(new com.ibm.icu.math.BigDecimal("3"), mcdef)
03124: .toString()).equals("6");
03125: (new Test("mul002")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
03126: .multiply(new com.ibm.icu.math.BigDecimal("1"), mcdef)
03127: .toString()).equals("5");
03128: (new Test("mul003")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
03129: .multiply(new com.ibm.icu.math.BigDecimal("2"), mcdef)
03130: .toString()).equals("10");
03131: (new Test("mul004")).ok = ((new com.ibm.icu.math.BigDecimal(
03132: "1.20")).multiply(new com.ibm.icu.math.BigDecimal("2"),
03133: mcdef).toString()).equals("2.40");
03134: (new Test("mul005")).ok = ((new com.ibm.icu.math.BigDecimal(
03135: "1.20")).multiply(new com.ibm.icu.math.BigDecimal("0"),
03136: mcdef).toString()).equals("0");
03137: (new Test("mul006")).ok = ((new com.ibm.icu.math.BigDecimal(
03138: "1.20")).multiply(
03139: new com.ibm.icu.math.BigDecimal("-2"), mcdef)
03140: .toString()).equals("-2.40");
03141: (new Test("mul007")).ok = ((new com.ibm.icu.math.BigDecimal(
03142: "-1.20")).multiply(
03143: new com.ibm.icu.math.BigDecimal("2"), mcdef).toString())
03144: .equals("-2.40");
03145: (new Test("mul008")).ok = ((new com.ibm.icu.math.BigDecimal(
03146: "-1.20")).multiply(
03147: new com.ibm.icu.math.BigDecimal("0"), mcdef).toString())
03148: .equals("0");
03149: (new Test("mul009")).ok = ((new com.ibm.icu.math.BigDecimal(
03150: "-1.20")).multiply(
03151: new com.ibm.icu.math.BigDecimal("-2"), mcdef)
03152: .toString()).equals("2.40");
03153: (new Test("mul010")).ok = ((new com.ibm.icu.math.BigDecimal(
03154: "5.09")).multiply(
03155: new com.ibm.icu.math.BigDecimal("7.1"), mcdef)
03156: .toString()).equals("36.139");
03157: (new Test("mul011")).ok = ((new com.ibm.icu.math.BigDecimal(
03158: "2.5")).multiply(new com.ibm.icu.math.BigDecimal("4"),
03159: mcdef).toString()).equals("10.0");
03160: (new Test("mul012")).ok = ((new com.ibm.icu.math.BigDecimal(
03161: "2.50")).multiply(new com.ibm.icu.math.BigDecimal("4"),
03162: mcdef).toString()).equals("10.00");
03163: (new Test("mul013")).ok = ((new com.ibm.icu.math.BigDecimal(
03164: "1.23456789")).multiply(
03165: new com.ibm.icu.math.BigDecimal("1.00000000"), mcdef)
03166: .toString()).equals("1.23456789");
03167:
03168: (new Test("mul014")).ok = ((new com.ibm.icu.math.BigDecimal(
03169: "9.999999999")).multiply(
03170: new com.ibm.icu.math.BigDecimal("9.999999999"), mcdef)
03171: .toString()).equals("100.000000");
03172:
03173: (new Test("mul015")).ok = ((new com.ibm.icu.math.BigDecimal(
03174: "2.50")).multiply(new com.ibm.icu.math.BigDecimal("4"),
03175: mcdef).toString()).equals("10.00");
03176: (new Test("mul016")).ok = ((new com.ibm.icu.math.BigDecimal(
03177: "2.50")).multiply(new com.ibm.icu.math.BigDecimal("4"),
03178: mc6).toString()).equals("10.00");
03179: (new Test("mul017")).ok = ((new com.ibm.icu.math.BigDecimal(
03180: "9.999999999")).multiply(
03181: new com.ibm.icu.math.BigDecimal("9.999999999"), mc6)
03182: .toString()).equals("100.000");
03183:
03184: (new Test("mul020")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
03185: .multiply(new com.ibm.icu.math.BigDecimal("3"))
03186: .toString()).equals("6");
03187: (new Test("mul021")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
03188: .multiply(new com.ibm.icu.math.BigDecimal("1"))
03189: .toString()).equals("5");
03190: (new Test("mul022")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
03191: .multiply(new com.ibm.icu.math.BigDecimal("2"))
03192: .toString()).equals("10");
03193: (new Test("mul023")).ok = ((new com.ibm.icu.math.BigDecimal(
03194: "1.20")).multiply(new com.ibm.icu.math.BigDecimal("2"))
03195: .toString()).equals("2.40");
03196: (new Test("mul024")).ok = ((new com.ibm.icu.math.BigDecimal(
03197: "1.20")).multiply(new com.ibm.icu.math.BigDecimal("0"))
03198: .toString()).equals("0.00");
03199: (new Test("mul025")).ok = ((new com.ibm.icu.math.BigDecimal(
03200: "1.20"))
03201: .multiply(new com.ibm.icu.math.BigDecimal("-2"))
03202: .toString()).equals("-2.40");
03203: (new Test("mul026")).ok = ((new com.ibm.icu.math.BigDecimal(
03204: "-1.20"))
03205: .multiply(new com.ibm.icu.math.BigDecimal("2"))
03206: .toString()).equals("-2.40");
03207: (new Test("mul027")).ok = ((new com.ibm.icu.math.BigDecimal(
03208: "-1.20"))
03209: .multiply(new com.ibm.icu.math.BigDecimal("0"))
03210: .toString()).equals("0.00");
03211: (new Test("mul028")).ok = ((new com.ibm.icu.math.BigDecimal(
03212: "-1.20"))
03213: .multiply(new com.ibm.icu.math.BigDecimal("-2"))
03214: .toString()).equals("2.40");
03215: (new Test("mul029")).ok = ((new com.ibm.icu.math.BigDecimal(
03216: "5.09"))
03217: .multiply(new com.ibm.icu.math.BigDecimal("7.1"))
03218: .toString()).equals("36.139");
03219: (new Test("mul030")).ok = ((new com.ibm.icu.math.BigDecimal(
03220: "2.5")).multiply(new com.ibm.icu.math.BigDecimal("4"))
03221: .toString()).equals("10.0");
03222: (new Test("mul031")).ok = ((new com.ibm.icu.math.BigDecimal(
03223: "2.50")).multiply(new com.ibm.icu.math.BigDecimal("4"))
03224: .toString()).equals("10.00");
03225: (new Test("mul032")).ok = ((new com.ibm.icu.math.BigDecimal(
03226: "1.23456789"))
03227: .multiply(new com.ibm.icu.math.BigDecimal("1.00000000"))
03228: .toString()).equals("1.2345678900000000");
03229:
03230: (new Test("mul033")).ok = ((new com.ibm.icu.math.BigDecimal(
03231: "1234.56789"))
03232: .multiply(new com.ibm.icu.math.BigDecimal("-1000.00000"))
03233: .toString()).equals("-1234567.8900000000");
03234:
03235: (new Test("mul034")).ok = ((new com.ibm.icu.math.BigDecimal(
03236: "-1234.56789"))
03237: .multiply(new com.ibm.icu.math.BigDecimal("1000.00000"))
03238: .toString()).equals("-1234567.8900000000");
03239:
03240: (new Test("mul035")).ok = ((new com.ibm.icu.math.BigDecimal(
03241: "9.999999999"))
03242: .multiply(new com.ibm.icu.math.BigDecimal("9.999999999"))
03243: .toString()).equals("99.999999980000000001");
03244:
03245: (new Test("mul036")).ok = ((new com.ibm.icu.math.BigDecimal(
03246: "5.00")).multiply(new com.ibm.icu.math.BigDecimal(
03247: "1E-3")).toString()).equals("0.00500");
03248: (new Test("mul037")).ok = ((new com.ibm.icu.math.BigDecimal(
03249: "00.00")).multiply(new com.ibm.icu.math.BigDecimal(
03250: "0.000")).toString()).equals("0.00000");
03251: (new Test("mul038")).ok = ((new com.ibm.icu.math.BigDecimal(
03252: "00.00")).multiply(new com.ibm.icu.math.BigDecimal(
03253: "0E-3")).toString()).equals("0.00"); // rhs is '0'
03254: // 1999.12.21: next one is a edge case if intermediate longs are used
03255: (new Test("mul039")).ok = ((new com.ibm.icu.math.BigDecimal(
03256: "999999999999"))
03257: .multiply(new com.ibm.icu.math.BigDecimal("9765625"))
03258: .toString()).equals("9765624999990234375");
03259:
03260: l9 = new com.ibm.icu.math.BigDecimal("123456789E+10");
03261: l77e = new com.ibm.icu.math.BigDecimal("77E-20");
03262: (new Test("mul040")).ok = (l9
03263: .multiply(new com.ibm.icu.math.BigDecimal("3456757"))
03264: .toString()).equals("4267601195732730000000000");
03265: (new Test("mul041")).ok = (l9.multiply(
03266: new com.ibm.icu.math.BigDecimal("3456757"), mc3)
03267: .toString()).equals("4.26E+24");
03268: (new Test("mul042")).ok = (l9.multiply(l77e).toString())
03269: .equals("0.95061727530000000000");
03270: (new Test("mul043")).ok = (l9.multiply(l77e, mc3).toString())
03271: .equals("0.947");
03272: (new Test("mul044")).ok = (l77e.multiply(l9, mc3).toString())
03273: .equals("0.947");
03274:
03275: l12345 = new com.ibm.icu.math.BigDecimal("123.45");
03276: (new Test("mul050")).ok = (l12345.multiply(
03277: new com.ibm.icu.math.BigDecimal("1e11"), mcdef)
03278: .toString()).equals("1.2345E+13");
03279: (new Test("mul051")).ok = (l12345.multiply(
03280: new com.ibm.icu.math.BigDecimal("1e11"), mcs)
03281: .toString()).equals("1.2345E+13");
03282: (new Test("mul052")).ok = (l12345.multiply(
03283: new com.ibm.icu.math.BigDecimal("1e+9"), mce)
03284: .toString()).equals("123.45E+9");
03285: (new Test("mul053")).ok = (l12345.multiply(
03286: new com.ibm.icu.math.BigDecimal("1e10"), mce)
03287: .toString()).equals("1.2345E+12");
03288: (new Test("mul054")).ok = (l12345.multiply(
03289: new com.ibm.icu.math.BigDecimal("1e11"), mce)
03290: .toString()).equals("12.345E+12");
03291: (new Test("mul055")).ok = (l12345.multiply(
03292: new com.ibm.icu.math.BigDecimal("1e12"), mce)
03293: .toString()).equals("123.45E+12");
03294: (new Test("mul056")).ok = (l12345.multiply(
03295: new com.ibm.icu.math.BigDecimal("1e13"), mce)
03296: .toString()).equals("1.2345E+15");
03297:
03298: // test some cases that are close to exponent overflow
03299: (new Test("mul060")).ok = (one.multiply(
03300: new com.ibm.icu.math.BigDecimal("9e999999999"), mcs)
03301: .toString()).equals("9E+999999999");
03302: (new Test("mul061")).ok = (one.multiply(
03303: new com.ibm.icu.math.BigDecimal("9.9e999999999"), mcs)
03304: .toString()).equals("9.9E+999999999");
03305: (new Test("mul062")).ok = (one.multiply(
03306: new com.ibm.icu.math.BigDecimal("9.99e999999999"), mcs)
03307: .toString()).equals("9.99E+999999999");
03308: (new Test("mul063")).ok = (ten.multiply(
03309: new com.ibm.icu.math.BigDecimal("9e999999999"), mce)
03310: .toString()).equals("90E+999999999");
03311: (new Test("mul064")).ok = (ten.multiply(
03312: new com.ibm.icu.math.BigDecimal("9.9e999999999"), mce)
03313: .toString()).equals("99.0E+999999999");
03314: edge = new com.ibm.icu.math.BigDecimal("9.999e999999999");
03315: tenedge = ten.multiply(edge, mce);
03316: (new Test("mul065")).ok = (tenedge.toString())
03317: .equals("99.990E+999999999");
03318: hunedge = ten.multiply(tenedge, mce);
03319: (new Test("mul066")).ok = (hunedge.toString())
03320: .equals("999.900E+999999999");
03321: opo = new com.ibm.icu.math.BigDecimal("0.1"); // one tenth
03322: (new Test("mul067")).ok = (opo.multiply(
03323: new com.ibm.icu.math.BigDecimal("9e-999999998"), mcs)
03324: .toString()).equals("9E-999999999");
03325: (new Test("mul068")).ok = (opo.multiply(
03326: new com.ibm.icu.math.BigDecimal("99e-999999998"), mcs)
03327: .toString()).equals("9.9E-999999998");
03328: (new Test("mul069")).ok = (opo.multiply(
03329: new com.ibm.icu.math.BigDecimal("999e-999999998"), mcs)
03330: .toString()).equals("9.99E-999999997");
03331:
03332: (new Test("mul070")).ok = (opo.multiply(
03333: new com.ibm.icu.math.BigDecimal("9e-999999998"), mce)
03334: .toString()).equals("9E-999999999");
03335: (new Test("mul071")).ok = (opo.multiply(
03336: new com.ibm.icu.math.BigDecimal("99e-999999998"), mce)
03337: .toString()).equals("99E-999999999");
03338: (new Test("mul072")).ok = (opo.multiply(
03339: new com.ibm.icu.math.BigDecimal("999e-999999998"), mce)
03340: .toString()).equals("999E-999999999");
03341: (new Test("mul073")).ok = (opo.multiply(
03342: new com.ibm.icu.math.BigDecimal("999e-999999997"), mce)
03343: .toString()).equals("9.99E-999999996");
03344: (new Test("mul074")).ok = (opo
03345: .multiply(new com.ibm.icu.math.BigDecimal(
03346: "9999e-999999997"), mce).toString())
03347: .equals("99.99E-999999996");
03348: (new Test("mul074")).ok = (opo.multiply(
03349: new com.ibm.icu.math.BigDecimal("99999e-999999997"),
03350: mce).toString()).equals("999.99E-999999996");
03351:
03352: // test some intermediate lengths
03353: (new Test("mul080")).ok = (opo.multiply(
03354: new com.ibm.icu.math.BigDecimal("123456789"), mcs)
03355: .toString()).equals("12345678.9");
03356: (new Test("mul081")).ok = (opo.multiply(
03357: new com.ibm.icu.math.BigDecimal("12345678901234"), mcs)
03358: .toString()).equals("1.23456789E+12");
03359: (new Test("mul082")).ok = (opo.multiply(
03360: new com.ibm.icu.math.BigDecimal("123456789123456789"),
03361: mcs).toString()).equals("1.23456789E+16");
03362: (new Test("mul083")).ok = (opo.multiply(
03363: new com.ibm.icu.math.BigDecimal("123456789"), mcfd)
03364: .toString()).equals("12345678.9");
03365: (new Test("mul084")).ok = (opo
03366: .multiply(new com.ibm.icu.math.BigDecimal(
03367: "12345678901234"), mcfd).toString())
03368: .equals("1234567890123.4");
03369: (new Test("mul085")).ok = (opo.multiply(
03370: new com.ibm.icu.math.BigDecimal("123456789123456789"),
03371: mcfd).toString()).equals("12345678912345678.9");
03372:
03373: (new Test("mul090")).ok = ((new com.ibm.icu.math.BigDecimal(
03374: "123456789")).multiply(opo, mcs).toString())
03375: .equals("12345678.9");
03376: (new Test("mul091")).ok = ((new com.ibm.icu.math.BigDecimal(
03377: "12345678901234")).multiply(opo, mcs).toString())
03378: .equals("1.23456789E+12");
03379: (new Test("mul092")).ok = ((new com.ibm.icu.math.BigDecimal(
03380: "123456789123456789")).multiply(opo, mcs).toString())
03381: .equals("1.23456789E+16");
03382: (new Test("mul093")).ok = ((new com.ibm.icu.math.BigDecimal(
03383: "123456789")).multiply(opo, mcfd).toString())
03384: .equals("12345678.9");
03385: (new Test("mul094")).ok = ((new com.ibm.icu.math.BigDecimal(
03386: "12345678901234")).multiply(opo, mcfd).toString())
03387: .equals("1234567890123.4");
03388: (new Test("mul095")).ok = ((new com.ibm.icu.math.BigDecimal(
03389: "123456789123456789")).multiply(opo, mcfd).toString())
03390: .equals("12345678912345678.9");
03391:
03392: // test some more edge cases and carries
03393: (new Test("mul101")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03394: .multiply(new com.ibm.icu.math.BigDecimal("9"))
03395: .toString()).equals("81");
03396: (new Test("mul102")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03397: .multiply(new com.ibm.icu.math.BigDecimal("90"))
03398: .toString()).equals("810");
03399: (new Test("mul103")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03400: .multiply(new com.ibm.icu.math.BigDecimal("900"))
03401: .toString()).equals("8100");
03402: (new Test("mul104")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03403: .multiply(new com.ibm.icu.math.BigDecimal("9000"))
03404: .toString()).equals("81000");
03405: (new Test("mul105")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03406: .multiply(new com.ibm.icu.math.BigDecimal("90000"))
03407: .toString()).equals("810000");
03408: (new Test("mul106")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03409: .multiply(new com.ibm.icu.math.BigDecimal("900000"))
03410: .toString()).equals("8100000");
03411: (new Test("mul107")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03412: .multiply(new com.ibm.icu.math.BigDecimal("9000000"))
03413: .toString()).equals("81000000");
03414: (new Test("mul108")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03415: .multiply(new com.ibm.icu.math.BigDecimal("90000000"))
03416: .toString()).equals("810000000");
03417: (new Test("mul109")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03418: .multiply(new com.ibm.icu.math.BigDecimal("900000000"))
03419: .toString()).equals("8100000000");
03420: (new Test("mul110")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03421: .multiply(new com.ibm.icu.math.BigDecimal("9000000000"))
03422: .toString()).equals("81000000000");
03423: (new Test("mul111")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03424: .multiply(new com.ibm.icu.math.BigDecimal("90000000000"))
03425: .toString()).equals("810000000000");
03426: (new Test("mul112")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03427: .multiply(new com.ibm.icu.math.BigDecimal(
03428: "900000000000")).toString())
03429: .equals("8100000000000");
03430: (new Test("mul113")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03431: .multiply(new com.ibm.icu.math.BigDecimal(
03432: "9000000000000")).toString())
03433: .equals("81000000000000");
03434: (new Test("mul114")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03435: .multiply(new com.ibm.icu.math.BigDecimal(
03436: "90000000000000")).toString())
03437: .equals("810000000000000");
03438: (new Test("mul115")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03439: .multiply(new com.ibm.icu.math.BigDecimal(
03440: "900000000000000")).toString())
03441: .equals("8100000000000000");
03442: (new Test("mul116")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03443: .multiply(new com.ibm.icu.math.BigDecimal(
03444: "9000000000000000")).toString())
03445: .equals("81000000000000000");
03446: (new Test("mul117")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03447: .multiply(new com.ibm.icu.math.BigDecimal(
03448: "90000000000000000")).toString())
03449: .equals("810000000000000000");
03450: (new Test("mul118")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03451: .multiply(new com.ibm.icu.math.BigDecimal(
03452: "900000000000000000")).toString())
03453: .equals("8100000000000000000");
03454: (new Test("mul119")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03455: .multiply(new com.ibm.icu.math.BigDecimal(
03456: "9000000000000000000")).toString())
03457: .equals("81000000000000000000");
03458: (new Test("mul120")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03459: .multiply(new com.ibm.icu.math.BigDecimal(
03460: "90000000000000000000")).toString())
03461: .equals("810000000000000000000");
03462: (new Test("mul121")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03463: .multiply(new com.ibm.icu.math.BigDecimal(
03464: "900000000000000000000")).toString())
03465: .equals("8100000000000000000000");
03466: (new Test("mul122")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03467: .multiply(new com.ibm.icu.math.BigDecimal(
03468: "9000000000000000000000")).toString())
03469: .equals("81000000000000000000000");
03470: (new Test("mul123")).ok = ((new com.ibm.icu.math.BigDecimal("9"))
03471: .multiply(new com.ibm.icu.math.BigDecimal(
03472: "90000000000000000000000")).toString())
03473: .equals("810000000000000000000000");
03474: // test some more edge cases without carries
03475: (new Test("mul131")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03476: .multiply(new com.ibm.icu.math.BigDecimal("3"))
03477: .toString()).equals("9");
03478: (new Test("mul132")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03479: .multiply(new com.ibm.icu.math.BigDecimal("30"))
03480: .toString()).equals("90");
03481: (new Test("mul133")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03482: .multiply(new com.ibm.icu.math.BigDecimal("300"))
03483: .toString()).equals("900");
03484: (new Test("mul134")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03485: .multiply(new com.ibm.icu.math.BigDecimal("3000"))
03486: .toString()).equals("9000");
03487: (new Test("mul135")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03488: .multiply(new com.ibm.icu.math.BigDecimal("30000"))
03489: .toString()).equals("90000");
03490: (new Test("mul136")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03491: .multiply(new com.ibm.icu.math.BigDecimal("300000"))
03492: .toString()).equals("900000");
03493: (new Test("mul137")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03494: .multiply(new com.ibm.icu.math.BigDecimal("3000000"))
03495: .toString()).equals("9000000");
03496: (new Test("mul138")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03497: .multiply(new com.ibm.icu.math.BigDecimal("30000000"))
03498: .toString()).equals("90000000");
03499: (new Test("mul139")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03500: .multiply(new com.ibm.icu.math.BigDecimal("300000000"))
03501: .toString()).equals("900000000");
03502: (new Test("mul140")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03503: .multiply(new com.ibm.icu.math.BigDecimal("3000000000"))
03504: .toString()).equals("9000000000");
03505: (new Test("mul141")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03506: .multiply(new com.ibm.icu.math.BigDecimal("30000000000"))
03507: .toString()).equals("90000000000");
03508: (new Test("mul142")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03509: .multiply(new com.ibm.icu.math.BigDecimal(
03510: "300000000000")).toString())
03511: .equals("900000000000");
03512: (new Test("mul143")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03513: .multiply(new com.ibm.icu.math.BigDecimal(
03514: "3000000000000")).toString())
03515: .equals("9000000000000");
03516: (new Test("mul144")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03517: .multiply(new com.ibm.icu.math.BigDecimal(
03518: "30000000000000")).toString())
03519: .equals("90000000000000");
03520: (new Test("mul145")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03521: .multiply(new com.ibm.icu.math.BigDecimal(
03522: "300000000000000")).toString())
03523: .equals("900000000000000");
03524: (new Test("mul146")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03525: .multiply(new com.ibm.icu.math.BigDecimal(
03526: "3000000000000000")).toString())
03527: .equals("9000000000000000");
03528: (new Test("mul147")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03529: .multiply(new com.ibm.icu.math.BigDecimal(
03530: "30000000000000000")).toString())
03531: .equals("90000000000000000");
03532: (new Test("mul148")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03533: .multiply(new com.ibm.icu.math.BigDecimal(
03534: "300000000000000000")).toString())
03535: .equals("900000000000000000");
03536: (new Test("mul149")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03537: .multiply(new com.ibm.icu.math.BigDecimal(
03538: "3000000000000000000")).toString())
03539: .equals("9000000000000000000");
03540: (new Test("mul150")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03541: .multiply(new com.ibm.icu.math.BigDecimal(
03542: "30000000000000000000")).toString())
03543: .equals("90000000000000000000");
03544: (new Test("mul151")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03545: .multiply(new com.ibm.icu.math.BigDecimal(
03546: "300000000000000000000")).toString())
03547: .equals("900000000000000000000");
03548: (new Test("mul152")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03549: .multiply(new com.ibm.icu.math.BigDecimal(
03550: "3000000000000000000000")).toString())
03551: .equals("9000000000000000000000");
03552: (new Test("mul153")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
03553: .multiply(new com.ibm.icu.math.BigDecimal(
03554: "30000000000000000000000")).toString())
03555: .equals("90000000000000000000000");
03556:
03557: try {
03558: checknull: do {
03559: ten.multiply((com.ibm.icu.math.BigDecimal) null);
03560: flag = false;
03561: } while (false);
03562: } catch (java.lang.NullPointerException $55) {
03563: flag = true;
03564: }/*checknull*/
03565: (new Test("mul200")).ok = flag;
03566: try {
03567: checknull2: do {
03568: ten.multiply(ten, (com.ibm.icu.math.MathContext) null);
03569: flag = false;
03570: } while (false);
03571: } catch (java.lang.NullPointerException $56) {
03572: flag = true;
03573: }/*checknull2*/
03574: (new Test("mul201")).ok = flag;
03575:
03576: try {
03577: checkover: do {
03578: d1 = new com.ibm.icu.math.BigDecimal(
03579: "-1.23456789012345E-0");
03580: d2 = new com.ibm.icu.math.BigDecimal("9E+999999999");
03581: d1.multiply(d2, mcdef); // marginal overflow
03582: flag = false;
03583: } while (false);
03584: } catch (java.lang.ArithmeticException $57) {
03585: oe = $57;
03586: flag = (oe.getMessage())
03587: .equals("Exponent Overflow: 1000000000");
03588: }/*checkover*/
03589: (new Test("mul202")).ok = flag;
03590: try {
03591: checkover: do {
03592: d1 = new com.ibm.icu.math.BigDecimal("112");
03593: d2 = new com.ibm.icu.math.BigDecimal("9E+999999999");
03594: d1.multiply(d2, mce); // marginal overflow, engineering
03595: flag = false;
03596: } while (false);
03597: } catch (java.lang.ArithmeticException $58) {
03598: oe = $58;
03599: flag = (oe.getMessage())
03600: .equals("Exponent Overflow: 1000000002");
03601: }/*checkover*/
03602: (new Test("mul203")).ok = flag;
03603:
03604: try {
03605: checkover: do {
03606: d1 = new com.ibm.icu.math.BigDecimal("0.9");
03607: d2 = new com.ibm.icu.math.BigDecimal("1E-999999999");
03608: d1.multiply(d2, mcdef); // marginal negative overflow
03609: flag = false;
03610: } while (false);
03611: } catch (java.lang.ArithmeticException $59) {
03612: oe = $59;
03613: flag = (oe.getMessage())
03614: .equals("Exponent Overflow: -1000000000");
03615: }/*checkover*/
03616: (new Test("mul204")).ok = flag;
03617: try {
03618: checkover: do {
03619: d1 = new com.ibm.icu.math.BigDecimal("0.9");
03620: d2 = new com.ibm.icu.math.BigDecimal("1E-999999999");
03621: d1.multiply(d2, mce); // marginal negative overflow, engineering
03622: flag = false;
03623: } while (false);
03624: } catch (java.lang.ArithmeticException $60) {
03625: oe = $60;
03626: flag = (oe.getMessage())
03627: .equals("Exponent Overflow: -1000000002");
03628: }/*checkover*/
03629: (new Test("mul205")).ok = flag;
03630:
03631: try {
03632: checkdigits: do {
03633: tenlong.multiply(com.ibm.icu.math.BigDecimal.ONE, mcld);
03634: flag = false;
03635: } while (false);
03636: } catch (java.lang.ArithmeticException $61) {
03637: ae = $61;
03638: flag = (ae.getMessage()).equals("Too many digits:" + " "
03639: + tenlong.toString());
03640: }/*checkdigits*/
03641: (new Test("mul206")).ok = flag;
03642: try {
03643: checkdigits: do {
03644: com.ibm.icu.math.BigDecimal.TEN.multiply(tenlong, mcld);
03645: flag = false;
03646: } while (false);
03647: } catch (java.lang.ArithmeticException $62) {
03648: ae = $62;
03649: flag = (ae.getMessage()).equals("Too many digits:" + " "
03650: + tenlong.toString());
03651: }/*checkdigits*/
03652: (new Test("mul207")).ok = flag;
03653:
03654: summary("multiply");
03655: }
03656:
03657: /* ----------------------------------------------------------------- */
03658:
03659: /** Test the {@link com.ibm.icu.math.BigDecimal#negate} method. */
03660:
03661: public void diagnegate() {
03662: boolean flag = false;
03663: java.lang.ArithmeticException ae = null;
03664:
03665: (new Test("neg001")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
03666: .negate().toString()).equals("-2");
03667: (new Test("neg002")).ok = ((new com.ibm.icu.math.BigDecimal(
03668: "-2")).negate().toString()).equals("2");
03669: (new Test("neg003")).ok = ((new com.ibm.icu.math.BigDecimal(
03670: "2.00")).negate(mcdef).toString()).equals("-2.00");
03671: (new Test("neg004")).ok = ((new com.ibm.icu.math.BigDecimal(
03672: "-2.00")).negate(mcdef).toString()).equals("2.00");
03673: (new Test("neg005")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
03674: .negate(mcdef).toString()).equals("0");
03675: (new Test("neg006")).ok = ((new com.ibm.icu.math.BigDecimal(
03676: "0.00")).negate(mcdef).toString()).equals("0");
03677: (new Test("neg007")).ok = ((new com.ibm.icu.math.BigDecimal(
03678: "00.0")).negate(mcdef).toString()).equals("0");
03679: (new Test("neg008")).ok = ((new com.ibm.icu.math.BigDecimal(
03680: "00")).negate(mcdef).toString()).equals("0");
03681:
03682: (new Test("neg010")).ok = ((new com.ibm.icu.math.BigDecimal(
03683: "2.00")).negate().toString()).equals("-2.00");
03684: (new Test("neg011")).ok = ((new com.ibm.icu.math.BigDecimal(
03685: "-2.00")).negate().toString()).equals("2.00");
03686: (new Test("neg012")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
03687: .negate().toString()).equals("0");
03688: (new Test("neg013")).ok = ((new com.ibm.icu.math.BigDecimal(
03689: "0.00")).negate().toString()).equals("0.00");
03690: (new Test("neg014")).ok = ((new com.ibm.icu.math.BigDecimal(
03691: "00.0")).negate().toString()).equals("0.0");
03692: (new Test("neg015")).ok = ((new com.ibm.icu.math.BigDecimal(
03693: "00.00")).negate().toString()).equals("0.00");
03694: (new Test("neg016")).ok = ((new com.ibm.icu.math.BigDecimal(
03695: "00")).negate().toString()).equals("0");
03696:
03697: (new Test("neg020")).ok = ((new com.ibm.icu.math.BigDecimal(
03698: "-2000000")).negate().toString()).equals("2000000");
03699: (new Test("neg021")).ok = ((new com.ibm.icu.math.BigDecimal(
03700: "-2000000")).negate(mcdef).toString())
03701: .equals("2000000");
03702: (new Test("neg022")).ok = ((new com.ibm.icu.math.BigDecimal(
03703: "-2000000")).negate(mc6).toString())
03704: .equals("2.00000E+6");
03705: (new Test("neg023")).ok = ((new com.ibm.icu.math.BigDecimal(
03706: "2000000")).negate(mc6).toString())
03707: .equals("-2.00000E+6");
03708:
03709: try {
03710: checknull: do {
03711: ten.negate((com.ibm.icu.math.MathContext) null);
03712: flag = false;
03713: } while (false);
03714: } catch (java.lang.NullPointerException $63) {
03715: flag = true;
03716: }/*checknull*/
03717: (new Test("neg100")).ok = flag;
03718:
03719: try {
03720: checkdigits: do {
03721: tenlong.negate(mcld);
03722: flag = false;
03723: } while (false);
03724: } catch (java.lang.ArithmeticException $64) {
03725: ae = $64;
03726: flag = (ae.getMessage()).equals("Too many digits:" + " "
03727: + tenlong.toString());
03728: }/*checkdigits*/
03729: (new Test("neg101")).ok = flag;
03730: summary("negate");
03731: }
03732:
03733: /* ----------------------------------------------------------------- */
03734:
03735: /** Test the {@link com.ibm.icu.math.BigDecimal#plus} method. */
03736:
03737: public void diagplus() {
03738: boolean flag = false;
03739: com.ibm.icu.math.MathContext mche1;
03740: java.lang.ArithmeticException ae = null;
03741:
03742: (new Test("plu001")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
03743: .plus(mcdef).toString()).equals("2");
03744: (new Test("plu002")).ok = ((new com.ibm.icu.math.BigDecimal(
03745: "-2")).plus(mcdef).toString()).equals("-2");
03746: (new Test("plu003")).ok = ((new com.ibm.icu.math.BigDecimal(
03747: "2.00")).plus(mcdef).toString()).equals("2.00");
03748: (new Test("plu004")).ok = ((new com.ibm.icu.math.BigDecimal(
03749: "-2.00")).plus(mcdef).toString()).equals("-2.00");
03750: (new Test("plu005")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
03751: .plus(mcdef).toString()).equals("0");
03752: (new Test("plu006")).ok = ((new com.ibm.icu.math.BigDecimal(
03753: "0.00")).plus(mcdef).toString()).equals("0");
03754: (new Test("plu007")).ok = ((new com.ibm.icu.math.BigDecimal(
03755: "00.0")).plus(mcdef).toString()).equals("0");
03756: (new Test("plu008")).ok = ((new com.ibm.icu.math.BigDecimal(
03757: "00")).plus(mcdef).toString()).equals("0");
03758:
03759: (new Test("plu010")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
03760: .plus().toString()).equals("2");
03761: (new Test("plu011")).ok = ((new com.ibm.icu.math.BigDecimal(
03762: "-2")).plus().toString()).equals("-2");
03763: (new Test("plu012")).ok = ((new com.ibm.icu.math.BigDecimal(
03764: "2.00")).plus().toString()).equals("2.00");
03765: (new Test("plu013")).ok = ((new com.ibm.icu.math.BigDecimal(
03766: "-2.00")).plus().toString()).equals("-2.00");
03767: (new Test("plu014")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
03768: .plus().toString()).equals("0");
03769: (new Test("plu015")).ok = ((new com.ibm.icu.math.BigDecimal(
03770: "0.00")).plus().toString()).equals("0.00");
03771: (new Test("plu016")).ok = ((new com.ibm.icu.math.BigDecimal(
03772: "00.0")).plus().toString()).equals("0.0");
03773: (new Test("plu017")).ok = ((new com.ibm.icu.math.BigDecimal(
03774: "00.00")).plus().toString()).equals("0.00");
03775: (new Test("plu018")).ok = ((new com.ibm.icu.math.BigDecimal(
03776: "00")).plus().toString()).equals("0");
03777:
03778: (new Test("plu020")).ok = ((new com.ibm.icu.math.BigDecimal(
03779: "-2000000")).plus().toString()).equals("-2000000");
03780: (new Test("plu021")).ok = ((new com.ibm.icu.math.BigDecimal(
03781: "-2000000")).plus(mcdef).toString()).equals("-2000000");
03782: (new Test("plu022")).ok = ((new com.ibm.icu.math.BigDecimal(
03783: "-2000000")).plus(mc6).toString())
03784: .equals("-2.00000E+6");
03785: (new Test("plu023")).ok = ((new com.ibm.icu.math.BigDecimal(
03786: "2000000")).plus(mc6).toString()).equals("2.00000E+6");
03787:
03788: // try some exotic but silly rounding [format checks more varieties]
03789: // [this mostly ensures we can set up and pass the setting]
03790: mche1 = new com.ibm.icu.math.MathContext(1,
03791: com.ibm.icu.math.MathContext.SCIENTIFIC, false,
03792: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN);
03793: (new Test("plu030")).ok = ((new com.ibm.icu.math.BigDecimal(
03794: "0.24")).plus(mche1).toString()).equals("0.2");
03795: (new Test("plu031")).ok = ((new com.ibm.icu.math.BigDecimal(
03796: "0.25")).plus(mche1).toString()).equals("0.2");
03797: (new Test("plu032")).ok = ((new com.ibm.icu.math.BigDecimal(
03798: "0.26")).plus(mche1).toString()).equals("0.3");
03799: (new Test("plu033")).ok = ((new com.ibm.icu.math.BigDecimal(
03800: "0.14")).plus(mche1).toString()).equals("0.1");
03801: (new Test("plu034")).ok = ((new com.ibm.icu.math.BigDecimal(
03802: "0.15")).plus(mche1).toString()).equals("0.2");
03803: (new Test("plu035")).ok = ((new com.ibm.icu.math.BigDecimal(
03804: "0.16")).plus(mche1).toString()).equals("0.2");
03805:
03806: (new Test("plu040")).ok = ((new com.ibm.icu.math.BigDecimal(
03807: "0.251")).plus(mche1).toString()).equals("0.3");
03808: (new Test("plu041")).ok = ((new com.ibm.icu.math.BigDecimal(
03809: "0.151")).plus(mche1).toString()).equals("0.2");
03810:
03811: (new Test("plu050")).ok = ((new com.ibm.icu.math.BigDecimal(
03812: "-0.24")).plus(mche1).toString()).equals("-0.2");
03813: (new Test("plu051")).ok = ((new com.ibm.icu.math.BigDecimal(
03814: "-0.25")).plus(mche1).toString()).equals("-0.2");
03815: (new Test("plu052")).ok = ((new com.ibm.icu.math.BigDecimal(
03816: "-0.26")).plus(mche1).toString()).equals("-0.3");
03817: (new Test("plu053")).ok = ((new com.ibm.icu.math.BigDecimal(
03818: "-0.14")).plus(mche1).toString()).equals("-0.1");
03819: (new Test("plu054")).ok = ((new com.ibm.icu.math.BigDecimal(
03820: "-0.15")).plus(mche1).toString()).equals("-0.2");
03821: (new Test("plu055")).ok = ((new com.ibm.icu.math.BigDecimal(
03822: "-0.16")).plus(mche1).toString()).equals("-0.2");
03823:
03824: // more fixed, potential LHS swaps if done by add 0
03825: (new Test("plu060")).ok = ((new com.ibm.icu.math.BigDecimal(
03826: "-56267E-10")).plus().toString())
03827: .equals("-0.0000056267");
03828: (new Test("plu061")).ok = ((new com.ibm.icu.math.BigDecimal(
03829: "-56267E-5")).plus().toString()).equals("-0.56267");
03830: (new Test("plu062")).ok = ((new com.ibm.icu.math.BigDecimal(
03831: "-56267E-2")).plus().toString()).equals("-562.67");
03832: (new Test("plu063")).ok = ((new com.ibm.icu.math.BigDecimal(
03833: "-56267E-1")).plus().toString()).equals("-5626.7");
03834: (new Test("plu065")).ok = ((new com.ibm.icu.math.BigDecimal(
03835: "-56267E-0")).plus().toString()).equals("-56267");
03836:
03837: try {
03838: checknull: do {
03839: ten.plus((com.ibm.icu.math.MathContext) null);
03840: flag = false;
03841: } while (false);
03842: } catch (java.lang.NullPointerException $65) {
03843: flag = true;
03844: }/*checknull*/
03845: (new Test("plu100")).ok = flag;
03846:
03847: try {
03848: checkdigits: do {
03849: tenlong.plus(mcld);
03850: flag = false;
03851: } while (false);
03852: } catch (java.lang.ArithmeticException $66) {
03853: ae = $66;
03854: flag = (ae.getMessage()).equals("Too many digits:" + " "
03855: + tenlong.toString());
03856: }/*checkdigits*/
03857: (new Test("plu101")).ok = flag;
03858: summary("plus");
03859: }
03860:
03861: /* ----------------------------------------------------------------- */
03862:
03863: /** Test the {@link com.ibm.icu.math.BigDecimal#pow} method. */
03864:
03865: public void diagpow() {
03866: boolean flag;
03867: com.ibm.icu.math.BigDecimal x;
03868: com.ibm.icu.math.BigDecimal temp;
03869: int n = 0;
03870: com.ibm.icu.math.BigDecimal vx;
03871: com.ibm.icu.math.BigDecimal vn;
03872: java.lang.ArithmeticException ae = null;
03873: flag = true;
03874: (new Test("pow001")).ok = "1"
03875: .equals((new com.ibm.icu.math.BigDecimal("0.3")).pow(
03876: new com.ibm.icu.math.BigDecimal("0"), mcdef)
03877: .toString());
03878: (new Test("pow002")).ok = "0.3"
03879: .equals((new com.ibm.icu.math.BigDecimal("0.3")).pow(
03880: new com.ibm.icu.math.BigDecimal("1"), mcdef)
03881: .toString());
03882: (new Test("pow003")).ok = "0.3"
03883: .equals((new com.ibm.icu.math.BigDecimal("0.3")).pow(
03884: new com.ibm.icu.math.BigDecimal("1.00"), mcdef)
03885: .toString());
03886: (new Test("pow004")).ok = "0.09"
03887: .equals((new com.ibm.icu.math.BigDecimal("0.3")).pow(
03888: new com.ibm.icu.math.BigDecimal("2.00"), mcdef)
03889: .toString());
03890: (new Test("pow005")).ok = "0.09"
03891: .equals((new com.ibm.icu.math.BigDecimal("0.3")).pow(
03892: new com.ibm.icu.math.BigDecimal("2.000000000"),
03893: mcdef).toString());
03894: (new Test("pow006")).ok = ("1E-8")
03895: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
03896: new com.ibm.icu.math.BigDecimal("-8"), mcdef)
03897: .toString());
03898: (new Test("pow007")).ok = ("1E-7")
03899: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
03900: new com.ibm.icu.math.BigDecimal("-7"), mcdef)
03901: .toString());
03902: (new Test("pow008")).ok = "0.000001"
03903: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
03904: new com.ibm.icu.math.BigDecimal("-6"), mcdef)
03905: .toString());
03906: (new Test("pow009")).ok = "0.00001"
03907: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
03908: new com.ibm.icu.math.BigDecimal("-5"), mcdef)
03909: .toString());
03910: (new Test("pow010")).ok = "0.0001"
03911: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
03912: new com.ibm.icu.math.BigDecimal("-4"), mcdef)
03913: .toString());
03914: (new Test("pow011")).ok = "0.001"
03915: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
03916: new com.ibm.icu.math.BigDecimal("-3"), mcdef)
03917: .toString());
03918: (new Test("pow012")).ok = "0.01"
03919: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
03920: new com.ibm.icu.math.BigDecimal("-2"), mcdef)
03921: .toString());
03922: (new Test("pow013")).ok = "0.1"
03923: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
03924: new com.ibm.icu.math.BigDecimal("-1"), mcdef)
03925: .toString());
03926: (new Test("pow014")).ok = "1"
03927: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
03928: new com.ibm.icu.math.BigDecimal("0"), mcdef)
03929: .toString());
03930: (new Test("pow015")).ok = "10"
03931: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
03932: new com.ibm.icu.math.BigDecimal("1"), mcdef)
03933: .toString());
03934: (new Test("pow016")).ok = "100000000"
03935: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
03936: new com.ibm.icu.math.BigDecimal("8"), mcdef)
03937: .toString());
03938: (new Test("pow017")).ok = ("1E+9")
03939: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
03940: new com.ibm.icu.math.BigDecimal("9"), mcdef)
03941: .toString());
03942: (new Test("pow018")).ok = ("1E+99")
03943: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
03944: new com.ibm.icu.math.BigDecimal("99"), mcdef)
03945: .toString());
03946: (new Test("pow019")).ok = ("1E+999999999")
03947: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
03948: new com.ibm.icu.math.BigDecimal("999999999"),
03949: mcdef).toString());
03950: (new Test("pow020")).ok = ("1E+999999998")
03951: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
03952: new com.ibm.icu.math.BigDecimal("999999998"),
03953: mcdef).toString());
03954: (new Test("pow021")).ok = ("1E+999999997")
03955: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
03956: new com.ibm.icu.math.BigDecimal("999999997"),
03957: mcdef).toString());
03958: (new Test("pow022")).ok = ("1E+333333333")
03959: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
03960: new com.ibm.icu.math.BigDecimal("333333333"),
03961: mcdef).toString());
03962: (new Test("pow023")).ok = ("1E-333333333")
03963: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
03964: new com.ibm.icu.math.BigDecimal("-333333333"),
03965: mcdef).toString());
03966: (new Test("pow024")).ok = ("1E-999999998")
03967: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
03968: new com.ibm.icu.math.BigDecimal("-999999998"),
03969: mcdef).toString());
03970: (new Test("pow025")).ok = ("1E-999999999")
03971: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
03972: new com.ibm.icu.math.BigDecimal("-999999999"),
03973: mcdef).toString());
03974: (new Test("pow026")).ok = "0.5"
03975: .equals((new com.ibm.icu.math.BigDecimal("2")).pow(
03976: new com.ibm.icu.math.BigDecimal("-1"), mcdef)
03977: .toString());
03978: (new Test("pow027")).ok = "0.25"
03979: .equals((new com.ibm.icu.math.BigDecimal("2")).pow(
03980: new com.ibm.icu.math.BigDecimal("-2"), mcdef)
03981: .toString());
03982: (new Test("pow028")).ok = "0.0625"
03983: .equals((new com.ibm.icu.math.BigDecimal("2")).pow(
03984: new com.ibm.icu.math.BigDecimal("-4"), mcdef)
03985: .toString());
03986:
03987: (new Test("pow050")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
03988: .pow(new com.ibm.icu.math.BigDecimal("0"), mcdef)
03989: .toString()).equals("1");
03990: (new Test("pow051")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
03991: .pow(new com.ibm.icu.math.BigDecimal("1"), mcdef)
03992: .toString()).equals("0");
03993: (new Test("pow052")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
03994: .pow(new com.ibm.icu.math.BigDecimal("2"), mcdef)
03995: .toString()).equals("0");
03996: (new Test("pow053")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
03997: .pow(new com.ibm.icu.math.BigDecimal("0"), mcdef)
03998: .toString()).equals("1");
03999: (new Test("pow054")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
04000: .pow(new com.ibm.icu.math.BigDecimal("1"), mcdef)
04001: .toString()).equals("1");
04002: (new Test("pow055")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
04003: .pow(new com.ibm.icu.math.BigDecimal("2"), mcdef)
04004: .toString()).equals("1");
04005: (new Test("pow056")).ok = ((new com.ibm.icu.math.BigDecimal(
04006: "0.3"))
04007: .pow(new com.ibm.icu.math.BigDecimal("0"), mcdef)
04008: .toString()).equals("1");
04009: (new Test("pow057")).ok = ((new com.ibm.icu.math.BigDecimal(
04010: "10")).pow(
04011: new com.ibm.icu.math.BigDecimal("999999999"), mcdef)
04012: .toString()).equals("1E+999999999");
04013: (new Test("pow058")).ok = ((new com.ibm.icu.math.BigDecimal(
04014: "10")).pow(
04015: new com.ibm.icu.math.BigDecimal("999999998"), mcdef)
04016: .toString()).equals("1E+999999998");
04017: (new Test("pow059")).ok = ((new com.ibm.icu.math.BigDecimal(
04018: "10")).pow(
04019: new com.ibm.icu.math.BigDecimal("999999997"), mcdef)
04020: .toString()).equals("1E+999999997");
04021: (new Test("pow060")).ok = ((new com.ibm.icu.math.BigDecimal(
04022: "10")).pow(
04023: new com.ibm.icu.math.BigDecimal("333333333"), mcdef)
04024: .toString()).equals("1E+333333333");
04025: (new Test("pow061")).ok = ((new com.ibm.icu.math.BigDecimal(
04026: "10"))
04027: .pow(new com.ibm.icu.math.BigDecimal("77"), mcdef)
04028: .toString()).equals("1E+77");
04029: (new Test("pow062")).ok = ((new com.ibm.icu.math.BigDecimal(
04030: "10"))
04031: .pow(new com.ibm.icu.math.BigDecimal("22"), mcdef)
04032: .toString()).equals("1E+22");
04033: (new Test("pow063")).ok = ((new com.ibm.icu.math.BigDecimal(
04034: "10")).pow(new com.ibm.icu.math.BigDecimal("-77"),
04035: mcdef).toString()).equals("1E-77");
04036: (new Test("pow064")).ok = ((new com.ibm.icu.math.BigDecimal(
04037: "10")).pow(new com.ibm.icu.math.BigDecimal("-22"),
04038: mcdef).toString()).equals("1E-22");
04039: (new Test("pow065")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
04040: .pow(new com.ibm.icu.math.BigDecimal("-1"), mcdef)
04041: .toString()).equals("0.5");
04042: (new Test("pow066")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
04043: .pow(new com.ibm.icu.math.BigDecimal("-2"), mcdef)
04044: .toString()).equals("0.25");
04045: (new Test("pow067")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
04046: .pow(new com.ibm.icu.math.BigDecimal("-4"), mcdef)
04047: .toString()).equals("0.0625");
04048: (new Test("pow068")).ok = ((new com.ibm.icu.math.BigDecimal(
04049: "6.0"))
04050: .pow(new com.ibm.icu.math.BigDecimal("2"), mcdef)
04051: .toString()).equals("36");
04052: (new Test("pow069")).ok = ((new com.ibm.icu.math.BigDecimal(
04053: "-3")).pow(new com.ibm.icu.math.BigDecimal("2"), mcdef)
04054: .toString()).equals("9");/* from book */
04055: (new Test("pow070")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
04056: .pow(new com.ibm.icu.math.BigDecimal("2"), mcdef).pow(
04057: new com.ibm.icu.math.BigDecimal("3"), mcdef)
04058: .toString()).equals("64");/* from book */
04059:
04060: // 1998.12.14 Next test removed as pow() no longer rounds RHS [as per ANSI]
04061: // Test('pow071').ok=BigDecimal('2').pow(BigDecimal('2.000000001'),mcdef).toString == '4'/* check input rounding */
04062:
04063: /* General tests from original Rexx diagnostics */
04064: x = new com.ibm.icu.math.BigDecimal("0.5");
04065: temp = com.ibm.icu.math.BigDecimal.ONE;
04066: flag = true;
04067: {
04068: n = 1;
04069: n: for (; n <= 10; n++) {
04070: temp = temp.multiply(x).divide(
04071: com.ibm.icu.math.BigDecimal.ONE);
04072: flag = flag
04073: & (x.pow(new com.ibm.icu.math.BigDecimal(n),
04074: mcdef).toString()).equals(temp
04075: .toString());
04076: }
04077: }/*n*/
04078: (new Test("pow080")).ok = flag;
04079:
04080: x = new com.ibm.icu.math.BigDecimal("2");
04081: temp = com.ibm.icu.math.BigDecimal.ONE;
04082: flag = true;
04083: {
04084: n = 1;
04085: n: for (; n <= 29; n++) {
04086: temp = temp.multiply(x).divide(
04087: com.ibm.icu.math.BigDecimal.ONE);
04088: flag = flag
04089: & (x.pow(new com.ibm.icu.math.BigDecimal(n),
04090: mcdef).toString()).equals(temp
04091: .toString());
04092: flag = flag
04093: & (x.pow(new com.ibm.icu.math.BigDecimal(
04094: (int) -n), mcdef).toString())
04095: .equals(com.ibm.icu.math.BigDecimal.ONE
04096: .divide(temp, mcdef).toString());
04097: /* Note that rounding errors are possible for larger "n" */
04098: /* due to the information content of the exponent */
04099: }
04100: }/*n*/
04101: (new Test("pow081")).ok = flag;
04102:
04103: /* The Vienna case. Checks both setup and 1/acc working precision */
04104: // Modified 1998.12.14 as RHS no longer rounded before use (must fit)
04105: // Modified 1990.02.04 as LHS is now rounded (instead of truncated to guard)
04106: vx = new com.ibm.icu.math.BigDecimal("123456789E+10"); // lhs .. rounded to 1.23E+18
04107: vn = new com.ibm.icu.math.BigDecimal("-1.23000e+2"); // rhs .. [was: -1.23455e+2, rounds to -123]
04108: (new Test("pow090")).ok = (vx.pow(vn, mc3).toString())
04109: .equals("8.74E-2226");
04110:
04111: //- fixed point versions ---
04112: (new Test("pow101")).ok = "1"
04113: .equals((new com.ibm.icu.math.BigDecimal("0.3")).pow(
04114: new com.ibm.icu.math.BigDecimal("0"))
04115: .toString());
04116: (new Test("pow102")).ok = "0.3"
04117: .equals((new com.ibm.icu.math.BigDecimal("0.3")).pow(
04118: new com.ibm.icu.math.BigDecimal("1"))
04119: .toString());
04120: (new Test("pow103")).ok = "0.3"
04121: .equals((new com.ibm.icu.math.BigDecimal("0.3")).pow(
04122: new com.ibm.icu.math.BigDecimal("1.00"))
04123: .toString());
04124: (new Test("pow104")).ok = "0.09"
04125: .equals((new com.ibm.icu.math.BigDecimal("0.3")).pow(
04126: new com.ibm.icu.math.BigDecimal("2"))
04127: .toString());
04128: (new Test("pow105")).ok = "0.09"
04129: .equals((new com.ibm.icu.math.BigDecimal("0.3")).pow(
04130: new com.ibm.icu.math.BigDecimal("2.00"))
04131: .toString());
04132: (new Test("pow106")).ok = "10"
04133: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
04134: new com.ibm.icu.math.BigDecimal("1"))
04135: .toString());
04136: (new Test("pow107")).ok = "100000000"
04137: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
04138: new com.ibm.icu.math.BigDecimal("8"))
04139: .toString());
04140: (new Test("pow108")).ok = "1000000000"
04141: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
04142: new com.ibm.icu.math.BigDecimal("9"))
04143: .toString());
04144: (new Test("pow109")).ok = "10000000000"
04145: .equals((new com.ibm.icu.math.BigDecimal("10")).pow(
04146: new com.ibm.icu.math.BigDecimal("10"))
04147: .toString());
04148: (new Test("pow110")).ok = "1"
04149: .equals((new com.ibm.icu.math.BigDecimal("2")).pow(
04150: new com.ibm.icu.math.BigDecimal("0"))
04151: .toString());
04152: (new Test("pow111")).ok = "16"
04153: .equals((new com.ibm.icu.math.BigDecimal("2")).pow(
04154: new com.ibm.icu.math.BigDecimal("4"))
04155: .toString());
04156: (new Test("pow112")).ok = "256"
04157: .equals((new com.ibm.icu.math.BigDecimal("2")).pow(
04158: new com.ibm.icu.math.BigDecimal("8"))
04159: .toString());
04160: (new Test("pow113")).ok = "1024"
04161: .equals((new com.ibm.icu.math.BigDecimal("2")).pow(
04162: new com.ibm.icu.math.BigDecimal("10"))
04163: .toString());
04164: (new Test("pow114")).ok = "1.0510100501"
04165: .equals((new com.ibm.icu.math.BigDecimal("1.01")).pow(
04166: new com.ibm.icu.math.BigDecimal("5"))
04167: .toString());
04168:
04169: (new Test("pow120")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
04170: .pow(new com.ibm.icu.math.BigDecimal("0")).toString())
04171: .equals("1");
04172: (new Test("pow121")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
04173: .pow(new com.ibm.icu.math.BigDecimal("1")).toString())
04174: .equals("0");
04175: (new Test("pow122")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
04176: .pow(new com.ibm.icu.math.BigDecimal("2")).toString())
04177: .equals("0");
04178: (new Test("pow123")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
04179: .pow(new com.ibm.icu.math.BigDecimal("0")).toString())
04180: .equals("1");
04181: (new Test("pow144")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
04182: .pow(new com.ibm.icu.math.BigDecimal("1")).toString())
04183: .equals("1");
04184: (new Test("pow125")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
04185: .pow(new com.ibm.icu.math.BigDecimal("2")).toString())
04186: .equals("1");
04187: (new Test("pow126")).ok = ((new com.ibm.icu.math.BigDecimal(
04188: "0.3")).pow(new com.ibm.icu.math.BigDecimal("0"))
04189: .toString()).equals("1");
04190: (new Test("pow127")).ok = ((new com.ibm.icu.math.BigDecimal(
04191: "10")).pow(new com.ibm.icu.math.BigDecimal("7"))
04192: .toString()).equals("10000000");
04193: (new Test("pow128")).ok = ((new com.ibm.icu.math.BigDecimal(
04194: "6.0")).pow(new com.ibm.icu.math.BigDecimal("2"))
04195: .toString()).equals("36.00");
04196: (new Test("pow129")).ok = ((new com.ibm.icu.math.BigDecimal(
04197: "6.00")).pow(new com.ibm.icu.math.BigDecimal("2"))
04198: .toString()).equals("36.0000");
04199: (new Test("pow130")).ok = ((new com.ibm.icu.math.BigDecimal(
04200: "6.000")).pow(new com.ibm.icu.math.BigDecimal("2"))
04201: .toString()).equals("36.000000");
04202: (new Test("pow131")).ok = ((new com.ibm.icu.math.BigDecimal(
04203: "-3")).pow(new com.ibm.icu.math.BigDecimal("2"))
04204: .toString()).equals("9");
04205: (new Test("pow132")).ok = ((new com.ibm.icu.math.BigDecimal("2"))
04206: .pow(new com.ibm.icu.math.BigDecimal("2")).pow(
04207: new com.ibm.icu.math.BigDecimal("3"))
04208: .toString()).equals("64");
04209:
04210: /* errors */
04211: try {
04212: checknull: do {
04213: ten.pow((com.ibm.icu.math.BigDecimal) null);
04214: flag = false;
04215: } while (false);
04216: } catch (java.lang.NullPointerException $67) {
04217: flag = true;
04218: }/*checknull*/
04219: (new Test("pow150")).ok = flag;
04220: try {
04221: checknull2: do {
04222: ten.pow(ten, (com.ibm.icu.math.MathContext) null);
04223: flag = false;
04224: } while (false);
04225: } catch (java.lang.NullPointerException $68) {
04226: flag = true;
04227: }/*checknull2*/
04228: (new Test("pow151")).ok = flag;
04229:
04230: flag = true;
04231: try {
04232: checkdigits: do {
04233: tenlong.pow(com.ibm.icu.math.BigDecimal.ONE, mcld);
04234: flag = false;
04235: } while (false);
04236: } catch (java.lang.ArithmeticException $69) {
04237: ae = $69;
04238: flag = (ae.getMessage()).equals("Too many digits:" + " "
04239: + tenlong.toString());
04240: }/*checkdigits*/
04241: (new Test("pow152")).ok = flag;
04242:
04243: try {
04244: checkdigits: do {
04245: com.ibm.icu.math.BigDecimal.ONE.pow(tenlong, mcld);
04246: flag = false;
04247: } while (false);
04248: } catch (java.lang.ArithmeticException $70) {
04249: ae = $70;
04250: flag = (ae.getMessage()).equals("Too many digits:" + " "
04251: + tenlong.toString());
04252: }/*checkdigits*/
04253: (new Test("pow153")).ok = flag;
04254:
04255: try {
04256: checkpos: do {
04257: com.ibm.icu.math.BigDecimal.ONE
04258: .pow(new com.ibm.icu.math.BigDecimal("-71"));
04259: flag = false;
04260: } while (false);
04261: } catch (java.lang.ArithmeticException $71) {
04262: ae = $71;
04263: flag = (ae.getMessage()).equals("Negative power: -71");
04264: }/*checkpos*/
04265: (new Test("pow154")).ok = flag;
04266:
04267: try {
04268: checkwhole: do {
04269: com.ibm.icu.math.BigDecimal.ONE.pow(
04270: new com.ibm.icu.math.BigDecimal("1234"), mc3);
04271: flag = false;
04272: } while (false);
04273: } catch (java.lang.ArithmeticException $72) {
04274: ae = $72;
04275: flag = (ae.getMessage()).equals("Too many digits: 1234");
04276: }/*checkwhole*/
04277: (new Test("pow155")).ok = flag;
04278:
04279: try {
04280: checkwhole1: do {
04281: com.ibm.icu.math.BigDecimal.ONE.pow(
04282: new com.ibm.icu.math.BigDecimal("12.34e+2"),
04283: mc3);
04284: flag = false;
04285: } while (false);
04286: } catch (java.lang.ArithmeticException $73) {
04287: ae = $73;
04288: flag = (ae.getMessage())
04289: .equals("Too many digits: 1.234E+3");
04290: }/*checkwhole1*/
04291: (new Test("pow156")).ok = flag;
04292:
04293: try {
04294: checkwhole2: do {
04295: com.ibm.icu.math.BigDecimal.ONE.pow(
04296: new com.ibm.icu.math.BigDecimal("12.4"), mcdef);
04297: flag = false;
04298: } while (false);
04299: } catch (java.lang.ArithmeticException $74) {
04300: ae = $74;
04301: flag = (ae.getMessage())
04302: .equals("Decimal part non-zero: 12.4");
04303: }/*checkwhole2*/
04304: (new Test("pow157")).ok = flag;
04305:
04306: try {
04307: checkwhole3: do {
04308: com.ibm.icu.math.BigDecimal.ONE.pow(
04309: new com.ibm.icu.math.BigDecimal("1.01"), mcdef);
04310: flag = false;
04311: } while (false);
04312: } catch (java.lang.ArithmeticException $75) {
04313: ae = $75;
04314: flag = (ae.getMessage())
04315: .equals("Decimal part non-zero: 1.01");
04316: }/*checkwhole3*/
04317: (new Test("pow158")).ok = flag;
04318:
04319: try {
04320: checkwhole4: do {
04321: com.ibm.icu.math.BigDecimal.ONE.pow(
04322: new com.ibm.icu.math.BigDecimal("1.000000001"),
04323: mcdef);
04324: flag = false;
04325: } while (false);
04326: } catch (java.lang.ArithmeticException $76) {
04327: ae = $76;
04328: flag = (ae.getMessage())
04329: .equals("Decimal part non-zero: 1.000000001");
04330: }/*checkwhole4*/
04331: (new Test("pow159")).ok = flag;
04332:
04333: try {
04334: checkwhole5: do {
04335: com.ibm.icu.math.BigDecimal.ONE.pow(
04336: new com.ibm.icu.math.BigDecimal("1.000000001"),
04337: mc3);
04338: flag = false;
04339: } while (false);
04340: } catch (java.lang.ArithmeticException $77) {
04341: ae = $77;
04342: flag = (ae.getMessage())
04343: .equals("Decimal part non-zero: 1.000000001");
04344: }/*checkwhole5*/
04345: (new Test("pow160")).ok = flag;
04346:
04347: try {
04348: checkwhole6: do {
04349: com.ibm.icu.math.BigDecimal.ONE.pow(
04350: new com.ibm.icu.math.BigDecimal(
04351: "5.67E-987654321"), mc3);
04352: flag = false;
04353: } while (false);
04354: } catch (java.lang.ArithmeticException $78) {
04355: ae = $78;
04356: flag = (ae.getMessage())
04357: .equals("Decimal part non-zero: 5.67E-987654321");
04358: }/*checkwhole6*/
04359: (new Test("pow161")).ok = flag;
04360:
04361: summary("pow");
04362: }
04363:
04364: /*--------------------------------------------------------------------*/
04365:
04366: /** Test the {@link com.ibm.icu.math.BigDecimal#remainder} method. */
04367:
04368: public void diagremainder() {
04369: boolean flag = false;
04370: java.lang.ArithmeticException ae = null;
04371:
04372: (new Test("rem001")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
04373: .remainder(new com.ibm.icu.math.BigDecimal("3"), mcdef)
04374: .toString()).equals("1");
04375: (new Test("rem002")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
04376: .remainder(new com.ibm.icu.math.BigDecimal("5"), mcdef)
04377: .toString()).equals("0");
04378: (new Test("rem003")).ok = ((new com.ibm.icu.math.BigDecimal(
04379: "13")).remainder(new com.ibm.icu.math.BigDecimal("10"),
04380: mcdef).toString()).equals("3");
04381: (new Test("rem004")).ok = ((new com.ibm.icu.math.BigDecimal(
04382: "13")).remainder(new com.ibm.icu.math.BigDecimal("50"),
04383: mcdef).toString()).equals("13");
04384: (new Test("rem005")).ok = ((new com.ibm.icu.math.BigDecimal(
04385: "13")).remainder(
04386: new com.ibm.icu.math.BigDecimal("100"), mcdef)
04387: .toString()).equals("13");
04388: (new Test("rem006")).ok = ((new com.ibm.icu.math.BigDecimal(
04389: "13")).remainder(
04390: new com.ibm.icu.math.BigDecimal("1000"), mcdef)
04391: .toString()).equals("13");
04392: (new Test("rem007")).ok = ((new com.ibm.icu.math.BigDecimal(
04393: ".13")).remainder(one).toString()).equals("0.13");
04394: (new Test("rem008")).ok = ((new com.ibm.icu.math.BigDecimal(
04395: "0.133")).remainder(one).toString()).equals("0.133");
04396: (new Test("rem009")).ok = ((new com.ibm.icu.math.BigDecimal(
04397: "0.1033")).remainder(one).toString()).equals("0.1033");
04398: (new Test("rem010")).ok = ((new com.ibm.icu.math.BigDecimal(
04399: "1.033")).remainder(one).toString()).equals("0.033");
04400: (new Test("rem011")).ok = ((new com.ibm.icu.math.BigDecimal(
04401: "10.33")).remainder(one).toString()).equals("0.33");
04402: (new Test("rem012")).ok = ((new com.ibm.icu.math.BigDecimal(
04403: "10.33")).remainder(com.ibm.icu.math.BigDecimal.TEN)
04404: .toString()).equals("0.33");
04405: (new Test("rem013")).ok = ((new com.ibm.icu.math.BigDecimal(
04406: "103.3")).remainder(com.ibm.icu.math.BigDecimal.ONE)
04407: .toString()).equals("0.3");
04408: (new Test("rem014")).ok = ((new com.ibm.icu.math.BigDecimal(
04409: "133")).remainder(com.ibm.icu.math.BigDecimal.TEN)
04410: .toString()).equals("3");
04411: (new Test("rem015")).ok = ((new com.ibm.icu.math.BigDecimal(
04412: "1033")).remainder(com.ibm.icu.math.BigDecimal.TEN)
04413: .toString()).equals("3");
04414: (new Test("rem016")).ok = ((new com.ibm.icu.math.BigDecimal(
04415: "1033")).remainder(new com.ibm.icu.math.BigDecimal(50),
04416: mcdef).toString()).equals("33");
04417: (new Test("rem017")).ok = ((new com.ibm.icu.math.BigDecimal(
04418: "101.0")).remainder(new com.ibm.icu.math.BigDecimal(3),
04419: mcdef).toString()).equals("2.0");
04420: (new Test("rem018")).ok = ((new com.ibm.icu.math.BigDecimal(
04421: "102.0")).remainder(new com.ibm.icu.math.BigDecimal(3),
04422: mcdef).toString()).equals("0");
04423: (new Test("rem019")).ok = ((new com.ibm.icu.math.BigDecimal(
04424: "103.0")).remainder(new com.ibm.icu.math.BigDecimal(3),
04425: mcdef).toString()).equals("1.0");
04426: (new Test("rem020")).ok = ((new com.ibm.icu.math.BigDecimal(
04427: "2.40")).remainder(one).toString()).equals("0.40");
04428: (new Test("rem021")).ok = ((new com.ibm.icu.math.BigDecimal(
04429: "2.400")).remainder(one).toString()).equals("0.400");
04430: (new Test("rem022")).ok = ((new com.ibm.icu.math.BigDecimal(
04431: "2.4")).remainder(one).toString()).equals("0.4");
04432: (new Test("rem023")).ok = ((new com.ibm.icu.math.BigDecimal(
04433: "2.4")).remainder(new com.ibm.icu.math.BigDecimal(2),
04434: mcdef).toString()).equals("0.4");
04435: (new Test("rem024")).ok = ((new com.ibm.icu.math.BigDecimal(
04436: "2.400")).remainder(new com.ibm.icu.math.BigDecimal(2),
04437: mcdef).toString()).equals("0.400");
04438: (new Test("rem025")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
04439: .remainder(new com.ibm.icu.math.BigDecimal("0.3"),
04440: mcdef).toString()).equals("0.1");
04441: (new Test("rem026")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
04442: .remainder(new com.ibm.icu.math.BigDecimal("0.30"),
04443: mcdef).toString()).equals("0.10");
04444: (new Test("rem027")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
04445: .remainder(new com.ibm.icu.math.BigDecimal("0.300"),
04446: mcdef).toString()).equals("0.100");
04447: (new Test("rem028")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
04448: .remainder(new com.ibm.icu.math.BigDecimal("0.3000"),
04449: mcdef).toString()).equals("0.1000");
04450: (new Test("rem029")).ok = ((new com.ibm.icu.math.BigDecimal(
04451: "1.0")).remainder(
04452: new com.ibm.icu.math.BigDecimal("0.3"), mcdef)
04453: .toString()).equals("0.1");
04454: (new Test("rem030")).ok = ((new com.ibm.icu.math.BigDecimal(
04455: "1.00")).remainder(new com.ibm.icu.math.BigDecimal(
04456: "0.3"), mcdef).toString()).equals("0.10");
04457: (new Test("rem031")).ok = ((new com.ibm.icu.math.BigDecimal(
04458: "1.000")).remainder(new com.ibm.icu.math.BigDecimal(
04459: "0.3"), mcdef).toString()).equals("0.100");
04460: (new Test("rem032")).ok = ((new com.ibm.icu.math.BigDecimal(
04461: "1.0000")).remainder(new com.ibm.icu.math.BigDecimal(
04462: "0.3"), mcdef).toString()).equals("0.1000");
04463: (new Test("rem033")).ok = ((new com.ibm.icu.math.BigDecimal(
04464: "0.5")).remainder(new com.ibm.icu.math.BigDecimal(
04465: "2.001"), mcdef).toString()).equals("0.5");
04466:
04467: (new Test("rem040")).ok = ((new com.ibm.icu.math.BigDecimal(
04468: "0.5")).remainder(new com.ibm.icu.math.BigDecimal(
04469: "0.5000001"), mcdef).toString()).equals("0.5");
04470: (new Test("rem041")).ok = ((new com.ibm.icu.math.BigDecimal(
04471: "0.5")).remainder(new com.ibm.icu.math.BigDecimal(
04472: "0.50000001"), mcdef).toString()).equals("0.5");
04473: (new Test("rem042")).ok = ((new com.ibm.icu.math.BigDecimal(
04474: "0.5")).remainder(new com.ibm.icu.math.BigDecimal(
04475: "0.500000001"), mcdef).toString()).equals("0.5");
04476: (new Test("rem043")).ok = ((new com.ibm.icu.math.BigDecimal(
04477: "0.5")).remainder(new com.ibm.icu.math.BigDecimal(
04478: "0.5000000001"), mcdef).toString()).equals("0");
04479: (new Test("rem044")).ok = ((new com.ibm.icu.math.BigDecimal(
04480: "0.5")).remainder(new com.ibm.icu.math.BigDecimal(
04481: "0.50000000001"), mcdef).toString()).equals("0");
04482: (new Test("rem045")).ok = ((new com.ibm.icu.math.BigDecimal(
04483: "0.5")).remainder(new com.ibm.icu.math.BigDecimal(
04484: "0.4999999"), mcdef).toString()).equals("1E-7");
04485: (new Test("rem046")).ok = ((new com.ibm.icu.math.BigDecimal(
04486: "0.5")).remainder(new com.ibm.icu.math.BigDecimal(
04487: "0.49999999"), mcdef).toString()).equals("1E-8");
04488: (new Test("rem047")).ok = ((new com.ibm.icu.math.BigDecimal(
04489: "0.5")).remainder(new com.ibm.icu.math.BigDecimal(
04490: "0.499999999"), mcdef).toString()).equals("1E-9");
04491: (new Test("rem048")).ok = ((new com.ibm.icu.math.BigDecimal(
04492: "0.5")).remainder(new com.ibm.icu.math.BigDecimal(
04493: "0.4999999999"), mcdef).toString()).equals("0");
04494: (new Test("rem049")).ok = ((new com.ibm.icu.math.BigDecimal(
04495: "0.5")).remainder(new com.ibm.icu.math.BigDecimal(
04496: "0.49999999999"), mcdef).toString()).equals("0");
04497:
04498: (new Test("rem050")).ok = ((new com.ibm.icu.math.BigDecimal(
04499: "0.03")).remainder(
04500: new com.ibm.icu.math.BigDecimal("7"), mcdef).toString())
04501: .equals("0.03");
04502: (new Test("rem051")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
04503: .remainder(new com.ibm.icu.math.BigDecimal("2"), mcdef)
04504: .toString()).equals("1");
04505: (new Test("rem052")).ok = ((new com.ibm.icu.math.BigDecimal(
04506: "4.1")).remainder(new com.ibm.icu.math.BigDecimal("2"),
04507: mcdef).toString()).equals("0.1");
04508: (new Test("rem053")).ok = ((new com.ibm.icu.math.BigDecimal(
04509: "4.01")).remainder(
04510: new com.ibm.icu.math.BigDecimal("2"), mcdef).toString())
04511: .equals("0.01");
04512: (new Test("rem054")).ok = ((new com.ibm.icu.math.BigDecimal(
04513: "4.001")).remainder(
04514: new com.ibm.icu.math.BigDecimal("2"), mcdef).toString())
04515: .equals("0.001");
04516: (new Test("rem055")).ok = ((new com.ibm.icu.math.BigDecimal(
04517: "4.0001")).remainder(new com.ibm.icu.math.BigDecimal(
04518: "2"), mcdef).toString()).equals("0.0001");
04519: (new Test("rem056")).ok = ((new com.ibm.icu.math.BigDecimal(
04520: "4.00001")).remainder(new com.ibm.icu.math.BigDecimal(
04521: "2"), mcdef).toString()).equals("0.00001");
04522: (new Test("rem057")).ok = ((new com.ibm.icu.math.BigDecimal(
04523: "4.000001")).remainder(new com.ibm.icu.math.BigDecimal(
04524: "2"), mcdef).toString()).equals("0.000001");
04525: (new Test("rem058")).ok = ((new com.ibm.icu.math.BigDecimal(
04526: "4.0000001")).remainder(
04527: new com.ibm.icu.math.BigDecimal("2"), mcdef).toString())
04528: .equals("1E-7");
04529:
04530: (new Test("rem060")).ok = ((new com.ibm.icu.math.BigDecimal(
04531: "1.2")).remainder(new com.ibm.icu.math.BigDecimal(
04532: "0.7345"), mcdef).toString()).equals("0.4655");
04533: (new Test("rem061")).ok = ((new com.ibm.icu.math.BigDecimal(
04534: "0.8")).remainder(
04535: new com.ibm.icu.math.BigDecimal("12"), mcdef)
04536: .toString()).equals("0.8");
04537: (new Test("rem062")).ok = ((new com.ibm.icu.math.BigDecimal(
04538: "0.8")).remainder(
04539: new com.ibm.icu.math.BigDecimal("0.2"), mcdef)
04540: .toString()).equals("0");
04541: (new Test("rem063")).ok = ((new com.ibm.icu.math.BigDecimal(
04542: "0.8")).remainder(
04543: new com.ibm.icu.math.BigDecimal("0.3"), mcdef)
04544: .toString()).equals("0.2");
04545: (new Test("rem064")).ok = ((new com.ibm.icu.math.BigDecimal(
04546: "0.800")).remainder(new com.ibm.icu.math.BigDecimal(
04547: "12"), mcdef).toString()).equals("0.800");
04548: (new Test("rem065")).ok = ((new com.ibm.icu.math.BigDecimal(
04549: "0.800")).remainder(new com.ibm.icu.math.BigDecimal(
04550: "1.7"), mcdef).toString()).equals("0.800");
04551: (new Test("rem066")).ok = ((new com.ibm.icu.math.BigDecimal(
04552: "2.400")).remainder(new com.ibm.icu.math.BigDecimal(2),
04553: mcdef).toString()).equals("0.400");
04554:
04555: // MC --
04556: (new Test("rem071")).ok = ((new com.ibm.icu.math.BigDecimal(
04557: "2.400")).remainder(new com.ibm.icu.math.BigDecimal(2),
04558: mc6).toString()).equals("0.400");
04559: (new Test("rem072")).ok = ((new com.ibm.icu.math.BigDecimal(
04560: "12345678900000")).remainder(
04561: new com.ibm.icu.math.BigDecimal("12e+12"), mc3)
04562: .toString()).equals("3E+11");
04563:
04564: // Fixed --
04565: (new Test("rem101")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
04566: .remainder(new com.ibm.icu.math.BigDecimal("3"))
04567: .toString()).equals("1");
04568: (new Test("rem102")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
04569: .remainder(new com.ibm.icu.math.BigDecimal("5"))
04570: .toString()).equals("0");
04571: (new Test("rem103")).ok = ((new com.ibm.icu.math.BigDecimal(
04572: "13")).remainder(new com.ibm.icu.math.BigDecimal("10"))
04573: .toString()).equals("3");
04574: (new Test("rem104")).ok = ((new com.ibm.icu.math.BigDecimal(
04575: "13")).remainder(new com.ibm.icu.math.BigDecimal("50"))
04576: .toString()).equals("13");
04577: (new Test("rem105")).ok = ((new com.ibm.icu.math.BigDecimal(
04578: "13"))
04579: .remainder(new com.ibm.icu.math.BigDecimal("100"))
04580: .toString()).equals("13");
04581: (new Test("rem106")).ok = ((new com.ibm.icu.math.BigDecimal(
04582: "13"))
04583: .remainder(new com.ibm.icu.math.BigDecimal("1000"))
04584: .toString()).equals("13");
04585: (new Test("rem107")).ok = ((new com.ibm.icu.math.BigDecimal(
04586: ".13")).remainder(one).toString()).equals("0.13");
04587: (new Test("rem108")).ok = ((new com.ibm.icu.math.BigDecimal(
04588: "0.133")).remainder(one).toString()).equals("0.133");
04589: (new Test("rem109")).ok = ((new com.ibm.icu.math.BigDecimal(
04590: "0.1033")).remainder(one).toString()).equals("0.1033");
04591: (new Test("rem110")).ok = ((new com.ibm.icu.math.BigDecimal(
04592: "1.033")).remainder(one).toString()).equals("0.033");
04593: (new Test("rem111")).ok = ((new com.ibm.icu.math.BigDecimal(
04594: "10.33")).remainder(one).toString()).equals("0.33");
04595: (new Test("rem112")).ok = ((new com.ibm.icu.math.BigDecimal(
04596: "10.33")).remainder(com.ibm.icu.math.BigDecimal.TEN)
04597: .toString()).equals("0.33");
04598: (new Test("rem113")).ok = ((new com.ibm.icu.math.BigDecimal(
04599: "103.3")).remainder(com.ibm.icu.math.BigDecimal.ONE)
04600: .toString()).equals("0.3");
04601: (new Test("rem114")).ok = ((new com.ibm.icu.math.BigDecimal(
04602: "133")).remainder(com.ibm.icu.math.BigDecimal.TEN)
04603: .toString()).equals("3");
04604: (new Test("rem115")).ok = ((new com.ibm.icu.math.BigDecimal(
04605: "1033")).remainder(com.ibm.icu.math.BigDecimal.TEN)
04606: .toString()).equals("3");
04607: (new Test("rem116")).ok = ((new com.ibm.icu.math.BigDecimal(
04608: "1033")).remainder(new com.ibm.icu.math.BigDecimal(50))
04609: .toString()).equals("33");
04610: (new Test("rem117")).ok = ((new com.ibm.icu.math.BigDecimal(
04611: "101.0")).remainder(new com.ibm.icu.math.BigDecimal(3))
04612: .toString()).equals("2.0");
04613: (new Test("rem118")).ok = ((new com.ibm.icu.math.BigDecimal(
04614: "102.0")).remainder(new com.ibm.icu.math.BigDecimal(3))
04615: .toString()).equals("0");
04616: (new Test("rem119")).ok = ((new com.ibm.icu.math.BigDecimal(
04617: "103.0")).remainder(new com.ibm.icu.math.BigDecimal(3))
04618: .toString()).equals("1.0");
04619: (new Test("rem120")).ok = ((new com.ibm.icu.math.BigDecimal(
04620: "2.40")).remainder(one).toString()).equals("0.40");
04621: (new Test("rem121")).ok = ((new com.ibm.icu.math.BigDecimal(
04622: "2.400")).remainder(one).toString()).equals("0.400");
04623: (new Test("rem122")).ok = ((new com.ibm.icu.math.BigDecimal(
04624: "2.4")).remainder(one).toString()).equals("0.4");
04625: (new Test("rem123")).ok = ((new com.ibm.icu.math.BigDecimal(
04626: "2.4")).remainder(new com.ibm.icu.math.BigDecimal(2))
04627: .toString()).equals("0.4");
04628: (new Test("rem124")).ok = ((new com.ibm.icu.math.BigDecimal(
04629: "2.400")).remainder(new com.ibm.icu.math.BigDecimal(2))
04630: .toString()).equals("0.400");
04631: (new Test("rem125")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
04632: .remainder(new com.ibm.icu.math.BigDecimal("0.3"))
04633: .toString()).equals("0.1");
04634: (new Test("rem126")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
04635: .remainder(new com.ibm.icu.math.BigDecimal("0.30"))
04636: .toString()).equals("0.10");
04637: (new Test("rem127")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
04638: .remainder(new com.ibm.icu.math.BigDecimal("0.300"))
04639: .toString()).equals("0.100");
04640: (new Test("rem128")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
04641: .remainder(new com.ibm.icu.math.BigDecimal("0.3000"))
04642: .toString()).equals("0.1000");
04643: (new Test("rem129")).ok = ((new com.ibm.icu.math.BigDecimal(
04644: "1.0"))
04645: .remainder(new com.ibm.icu.math.BigDecimal("0.3"))
04646: .toString()).equals("0.1");
04647: (new Test("rem130")).ok = ((new com.ibm.icu.math.BigDecimal(
04648: "1.00")).remainder(new com.ibm.icu.math.BigDecimal(
04649: "0.3")).toString()).equals("0.10");
04650: (new Test("rem131")).ok = ((new com.ibm.icu.math.BigDecimal(
04651: "1.000")).remainder(new com.ibm.icu.math.BigDecimal(
04652: "0.3")).toString()).equals("0.100");
04653: (new Test("rem132")).ok = ((new com.ibm.icu.math.BigDecimal(
04654: "1.0000")).remainder(new com.ibm.icu.math.BigDecimal(
04655: "0.3")).toString()).equals("0.1000");
04656: (new Test("rem133")).ok = ((new com.ibm.icu.math.BigDecimal(
04657: "0.5")).remainder(new com.ibm.icu.math.BigDecimal(
04658: "2.001")).toString()).equals("0.5");
04659: (new Test("rem134")).ok = ((new com.ibm.icu.math.BigDecimal(
04660: "0.5")).remainder(new com.ibm.icu.math.BigDecimal(
04661: "0.500000001")).toString()).equals("0.5");
04662: (new Test("rem135")).ok = ((new com.ibm.icu.math.BigDecimal(
04663: "0.5")).remainder(new com.ibm.icu.math.BigDecimal(
04664: "0.5000000001")).toString()).equals("0.5");
04665: (new Test("rem136")).ok = ((new com.ibm.icu.math.BigDecimal(
04666: "0.03"))
04667: .remainder(new com.ibm.icu.math.BigDecimal("7"))
04668: .toString()).equals("0.03");
04669: (new Test("rem137")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
04670: .remainder(new com.ibm.icu.math.BigDecimal("2"))
04671: .toString()).equals("1");
04672: (new Test("rem138")).ok = ((new com.ibm.icu.math.BigDecimal(
04673: "4.1")).remainder(new com.ibm.icu.math.BigDecimal("2"))
04674: .toString()).equals("0.1");
04675: (new Test("rem139")).ok = ((new com.ibm.icu.math.BigDecimal(
04676: "4.01"))
04677: .remainder(new com.ibm.icu.math.BigDecimal("2"))
04678: .toString()).equals("0.01");
04679: (new Test("rem140")).ok = ((new com.ibm.icu.math.BigDecimal(
04680: "4.001"))
04681: .remainder(new com.ibm.icu.math.BigDecimal("2"))
04682: .toString()).equals("0.001");
04683: (new Test("rem141")).ok = ((new com.ibm.icu.math.BigDecimal(
04684: "4.0001")).remainder(new com.ibm.icu.math.BigDecimal(
04685: "2")).toString()).equals("0.0001");
04686: (new Test("rem142")).ok = ((new com.ibm.icu.math.BigDecimal(
04687: "4.00001")).remainder(new com.ibm.icu.math.BigDecimal(
04688: "2")).toString()).equals("0.00001");
04689: (new Test("rem143")).ok = ((new com.ibm.icu.math.BigDecimal(
04690: "4.000001")).remainder(new com.ibm.icu.math.BigDecimal(
04691: "2")).toString()).equals("0.000001");
04692: (new Test("rem144")).ok = ((new com.ibm.icu.math.BigDecimal(
04693: "4.0000001"))
04694: .remainder(new com.ibm.icu.math.BigDecimal("2"))
04695: .toString()).equals("0.0000001"); // 1E-7, plain
04696: (new Test("rem145")).ok = ((new com.ibm.icu.math.BigDecimal(
04697: "1.2")).remainder(new com.ibm.icu.math.BigDecimal(
04698: "0.7345")).toString()).equals("0.4655");
04699: (new Test("rem146")).ok = ((new com.ibm.icu.math.BigDecimal(
04700: "0.8"))
04701: .remainder(new com.ibm.icu.math.BigDecimal("12"))
04702: .toString()).equals("0.8");
04703: (new Test("rem147")).ok = ((new com.ibm.icu.math.BigDecimal(
04704: "0.8"))
04705: .remainder(new com.ibm.icu.math.BigDecimal("0.2"))
04706: .toString()).equals("0");
04707: (new Test("rem148")).ok = ((new com.ibm.icu.math.BigDecimal(
04708: "0.8"))
04709: .remainder(new com.ibm.icu.math.BigDecimal("0.3"))
04710: .toString()).equals("0.2");
04711: (new Test("rem149")).ok = ((new com.ibm.icu.math.BigDecimal(
04712: "0.800")).remainder(new com.ibm.icu.math.BigDecimal(
04713: "12")).toString()).equals("0.800");
04714: (new Test("rem150")).ok = ((new com.ibm.icu.math.BigDecimal(
04715: "0.800")).remainder(new com.ibm.icu.math.BigDecimal(
04716: "1.7")).toString()).equals("0.800");
04717: (new Test("rem151")).ok = ((new com.ibm.icu.math.BigDecimal(
04718: "2.400")).remainder(new com.ibm.icu.math.BigDecimal(2),
04719: mcdef).toString()).equals("0.400");
04720:
04721: try {
04722: checknull: do {
04723: ten.remainder((com.ibm.icu.math.BigDecimal) null);
04724: flag = false;
04725: } while (false);
04726: } catch (java.lang.NullPointerException $79) {
04727: flag = true;
04728: }/*checknull*/
04729: (new Test("rem200")).ok = flag;
04730: try {
04731: checknull2: do {
04732: ten.remainder(ten, (com.ibm.icu.math.MathContext) null);
04733: flag = false;
04734: } while (false);
04735: } catch (java.lang.NullPointerException $80) {
04736: flag = true;
04737: }/*checknull2*/
04738: (new Test("rem201")).ok = flag;
04739:
04740: try {
04741: checkdigits: do {
04742: com.ibm.icu.math.BigDecimal.ONE
04743: .remainder(tenlong, mcld);
04744: flag = false;
04745: } while (false);
04746: } catch (java.lang.ArithmeticException $81) {
04747: ae = $81;
04748: flag = (ae.getMessage()).equals("Too many digits:" + " "
04749: + tenlong.toString());
04750: }/*checkdigits*/
04751: (new Test("rem202")).ok = flag;
04752:
04753: try {
04754: checkdigits: do {
04755: tenlong.remainder(one, mcld);
04756: flag = false;
04757: } while (false);
04758: } catch (java.lang.ArithmeticException $82) {
04759: ae = $82;
04760: flag = (ae.getMessage()).equals("Too many digits:" + " "
04761: + tenlong.toString());
04762: }/*checkdigits*/
04763: (new Test("rem203")).ok = flag;
04764:
04765: summary("remainder");
04766: }
04767:
04768: /*--------------------------------------------------------------------*/
04769:
04770: /** Test the {@link com.ibm.icu.math.BigDecimal#subtract} method. */
04771:
04772: public void diagsubtract() {
04773: boolean flag = false;
04774: com.ibm.icu.math.BigDecimal alhs;
04775: com.ibm.icu.math.BigDecimal arhs;
04776: java.lang.ArithmeticException ae = null;
04777:
04778: // [first group are 'quick confidence check']
04779: (new Test("sub301")).ok = ((new com.ibm.icu.math.BigDecimal(2))
04780: .subtract(new com.ibm.icu.math.BigDecimal(3), mcdef)
04781: .toString()).equals("-1");
04782: (new Test("sub302")).ok = ((new com.ibm.icu.math.BigDecimal(
04783: "5.75")).subtract(
04784: new com.ibm.icu.math.BigDecimal("3.3"), mcdef)
04785: .toString()).equals("2.45");
04786: (new Test("sub303")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
04787: .subtract(new com.ibm.icu.math.BigDecimal("-3"), mcdef)
04788: .toString()).equals("8");
04789: (new Test("sub304")).ok = ((new com.ibm.icu.math.BigDecimal(
04790: "-5")).subtract(new com.ibm.icu.math.BigDecimal("-3"),
04791: mcdef).toString()).equals("-2");
04792: (new Test("sub305")).ok = ((new com.ibm.icu.math.BigDecimal(
04793: "-7")).subtract(new com.ibm.icu.math.BigDecimal("2.5"),
04794: mcdef).toString()).equals("-9.5");
04795: (new Test("sub306")).ok = ((new com.ibm.icu.math.BigDecimal(
04796: "0.7")).subtract(
04797: new com.ibm.icu.math.BigDecimal("0.3"), mcdef)
04798: .toString()).equals("0.4");
04799: (new Test("sub307")).ok = ((new com.ibm.icu.math.BigDecimal(
04800: "1.3")).subtract(
04801: new com.ibm.icu.math.BigDecimal("0.3"), mcdef)
04802: .toString()).equals("1.0");
04803: (new Test("sub308")).ok = ((new com.ibm.icu.math.BigDecimal(
04804: "1.25")).subtract(new com.ibm.icu.math.BigDecimal(
04805: "1.25"), mcdef).toString()).equals("0");
04806: (new Test("sub309")).ok = ((new com.ibm.icu.math.BigDecimal(
04807: "1.23456789")).subtract(
04808: new com.ibm.icu.math.BigDecimal("1.00000000"), mcdef)
04809: .toString()).equals("0.23456789");
04810:
04811: (new Test("sub310")).ok = ((new com.ibm.icu.math.BigDecimal(
04812: "1.23456789")).subtract(
04813: new com.ibm.icu.math.BigDecimal("1.00000089"), mcdef)
04814: .toString()).equals("0.23456700");
04815:
04816: (new Test("sub311")).ok = ((new com.ibm.icu.math.BigDecimal(
04817: "0.5555555559")).subtract(
04818: new com.ibm.icu.math.BigDecimal("0.0000000001"), mcdef)
04819: .toString()).equals("0.555555556");
04820:
04821: (new Test("sub312")).ok = ((new com.ibm.icu.math.BigDecimal(
04822: "0.5555555559")).subtract(
04823: new com.ibm.icu.math.BigDecimal("0.0000000005"), mcdef)
04824: .toString()).equals("0.555555556");
04825:
04826: (new Test("sub313")).ok = ((new com.ibm.icu.math.BigDecimal(
04827: "0.4444444444")).subtract(
04828: new com.ibm.icu.math.BigDecimal("0.1111111111"), mcdef)
04829: .toString()).equals("0.333333333");
04830:
04831: (new Test("sub314")).ok = ((new com.ibm.icu.math.BigDecimal(
04832: "1.0000000000")).subtract(
04833: new com.ibm.icu.math.BigDecimal("0.00000001"), mcdef)
04834: .toString()).equals("0.99999999");
04835:
04836: (new Test("sub315")).ok = ((new com.ibm.icu.math.BigDecimal(
04837: "0.4444444444999")).subtract(
04838: new com.ibm.icu.math.BigDecimal("0"), mcdef).toString())
04839: .equals("0.444444444");
04840:
04841: (new Test("sub316")).ok = ((new com.ibm.icu.math.BigDecimal(
04842: "0.4444444445000")).subtract(
04843: new com.ibm.icu.math.BigDecimal("0"), mcdef).toString())
04844: .equals("0.444444445");
04845:
04846: (new Test("sub317")).ok = ((new com.ibm.icu.math.BigDecimal(
04847: "70")).subtract(new com.ibm.icu.math.BigDecimal(
04848: "10000e+9"), mcdef).toString())
04849: .equals("-1.00000000E+13");
04850:
04851: (new Test("sub318")).ok = ((new com.ibm.icu.math.BigDecimal(
04852: "700")).subtract(new com.ibm.icu.math.BigDecimal(
04853: "10000e+9"), mcdef).toString())
04854: .equals("-1.00000000E+13");
04855:
04856: (new Test("sub319")).ok = ((new com.ibm.icu.math.BigDecimal(
04857: "7000")).subtract(new com.ibm.icu.math.BigDecimal(
04858: "10000e+9"), mcdef).toString())
04859: .equals("-1.00000000E+13");
04860:
04861: (new Test("sub320")).ok = ((new com.ibm.icu.math.BigDecimal(
04862: "70000")).subtract(new com.ibm.icu.math.BigDecimal(
04863: "10000e+9"), mcdef).toString())
04864: .equals("-9.9999999E+12");
04865:
04866: (new Test("sub321")).ok = ((new com.ibm.icu.math.BigDecimal(
04867: "700000")).subtract(new com.ibm.icu.math.BigDecimal(
04868: "10000e+9"), mcdef).toString())
04869: .equals("-9.9999993E+12");
04870:
04871: // symmetry:
04872: (new Test("sub322")).ok = ((new com.ibm.icu.math.BigDecimal(
04873: "10000e+9")).subtract(new com.ibm.icu.math.BigDecimal(
04874: "70"), mcdef).toString()).equals("1.00000000E+13");
04875:
04876: (new Test("sub323")).ok = ((new com.ibm.icu.math.BigDecimal(
04877: "10000e+9")).subtract(new com.ibm.icu.math.BigDecimal(
04878: "700"), mcdef).toString()).equals("1.00000000E+13");
04879:
04880: (new Test("sub324")).ok = ((new com.ibm.icu.math.BigDecimal(
04881: "10000e+9")).subtract(new com.ibm.icu.math.BigDecimal(
04882: "7000"), mcdef).toString()).equals("1.00000000E+13");
04883:
04884: (new Test("sub325")).ok = ((new com.ibm.icu.math.BigDecimal(
04885: "10000e+9")).subtract(new com.ibm.icu.math.BigDecimal(
04886: "70000"), mcdef).toString()).equals("9.9999999E+12");
04887:
04888: (new Test("sub326")).ok = ((new com.ibm.icu.math.BigDecimal(
04889: "10000e+9")).subtract(new com.ibm.icu.math.BigDecimal(
04890: "700000"), mcdef).toString()).equals("9.9999993E+12");
04891:
04892: // [same with fixed point arithmetic]
04893: (new Test("sub001")).ok = ((new com.ibm.icu.math.BigDecimal(2))
04894: .subtract(new com.ibm.icu.math.BigDecimal(3))
04895: .toString()).equals("-1");
04896: (new Test("sub002")).ok = ((new com.ibm.icu.math.BigDecimal(
04897: "5.75"))
04898: .subtract(new com.ibm.icu.math.BigDecimal("3.3"))
04899: .toString()).equals("2.45");
04900: (new Test("sub003")).ok = ((new com.ibm.icu.math.BigDecimal("5"))
04901: .subtract(new com.ibm.icu.math.BigDecimal("-3"))
04902: .toString()).equals("8");
04903: (new Test("sub004")).ok = ((new com.ibm.icu.math.BigDecimal(
04904: "-5")).subtract(new com.ibm.icu.math.BigDecimal("-3"))
04905: .toString()).equals("-2");
04906: (new Test("sub005")).ok = ((new com.ibm.icu.math.BigDecimal(
04907: "-7")).subtract(new com.ibm.icu.math.BigDecimal("2.5"))
04908: .toString()).equals("-9.5");
04909: (new Test("sub006")).ok = ((new com.ibm.icu.math.BigDecimal(
04910: "0.7"))
04911: .subtract(new com.ibm.icu.math.BigDecimal("0.3"))
04912: .toString()).equals("0.4");
04913: (new Test("sub007")).ok = ((new com.ibm.icu.math.BigDecimal(
04914: "1.3"))
04915: .subtract(new com.ibm.icu.math.BigDecimal("0.3"))
04916: .toString()).equals("1.0");
04917: (new Test("sub008")).ok = ((new com.ibm.icu.math.BigDecimal(
04918: "1.25")).subtract(new com.ibm.icu.math.BigDecimal(
04919: "1.25")).toString()).equals("0.00");
04920: (new Test("sub009")).ok = ((new com.ibm.icu.math.BigDecimal(
04921: "0.02")).subtract(new com.ibm.icu.math.BigDecimal(
04922: "0.02")).toString()).equals("0.00");
04923:
04924: (new Test("sub010")).ok = ((new com.ibm.icu.math.BigDecimal(
04925: "1.23456789"))
04926: .subtract(new com.ibm.icu.math.BigDecimal("1.00000000"))
04927: .toString()).equals("0.23456789");
04928:
04929: (new Test("sub011")).ok = ((new com.ibm.icu.math.BigDecimal(
04930: "1.23456789"))
04931: .subtract(new com.ibm.icu.math.BigDecimal("1.00000089"))
04932: .toString()).equals("0.23456700");
04933:
04934: (new Test("sub012")).ok = ((new com.ibm.icu.math.BigDecimal(
04935: "0.5555555559"))
04936: .subtract(new com.ibm.icu.math.BigDecimal(
04937: "0.0000000001")).toString())
04938: .equals("0.5555555558");
04939:
04940: (new Test("sub013")).ok = ((new com.ibm.icu.math.BigDecimal(
04941: "0.5555555559"))
04942: .subtract(new com.ibm.icu.math.BigDecimal(
04943: "0.0000000005")).toString())
04944: .equals("0.5555555554");
04945:
04946: (new Test("sub014")).ok = ((new com.ibm.icu.math.BigDecimal(
04947: "0.4444444444"))
04948: .subtract(new com.ibm.icu.math.BigDecimal(
04949: "0.1111111111")).toString())
04950: .equals("0.3333333333");
04951:
04952: (new Test("sub015")).ok = ((new com.ibm.icu.math.BigDecimal(
04953: "1.0000000000"))
04954: .subtract(new com.ibm.icu.math.BigDecimal("0.00000001"))
04955: .toString()).equals("0.9999999900");
04956:
04957: (new Test("sub016")).ok = ((new com.ibm.icu.math.BigDecimal(
04958: "0.4444444444999"))
04959: .subtract(new com.ibm.icu.math.BigDecimal("0"))
04960: .toString()).equals("0.4444444444999");
04961:
04962: (new Test("sub017")).ok = ((new com.ibm.icu.math.BigDecimal(
04963: "0.4444444445000"))
04964: .subtract(new com.ibm.icu.math.BigDecimal("0"))
04965: .toString()).equals("0.4444444445000");
04966:
04967: (new Test("sub018")).ok = ((new com.ibm.icu.math.BigDecimal(
04968: "70")).subtract(new com.ibm.icu.math.BigDecimal(
04969: "10000e+9")).toString()).equals("-9999999999930");
04970:
04971: (new Test("sub019")).ok = ((new com.ibm.icu.math.BigDecimal(
04972: "700")).subtract(new com.ibm.icu.math.BigDecimal(
04973: "10000e+9")).toString()).equals("-9999999999300");
04974:
04975: (new Test("sub020")).ok = ((new com.ibm.icu.math.BigDecimal(
04976: "7000")).subtract(new com.ibm.icu.math.BigDecimal(
04977: "10000e+9")).toString()).equals("-9999999993000");
04978:
04979: (new Test("sub021")).ok = ((new com.ibm.icu.math.BigDecimal(
04980: "70000")).subtract(new com.ibm.icu.math.BigDecimal(
04981: "10000e+9")).toString()).equals("-9999999930000");
04982:
04983: (new Test("sub022")).ok = ((new com.ibm.icu.math.BigDecimal(
04984: "700000")).subtract(new com.ibm.icu.math.BigDecimal(
04985: "10000e+9")).toString()).equals("-9999999300000");
04986:
04987: // symmetry:
04988: (new Test("sub023")).ok = ((new com.ibm.icu.math.BigDecimal(
04989: "10000e+9")).subtract(new com.ibm.icu.math.BigDecimal(
04990: "70")).toString()).equals("9999999999930");
04991:
04992: (new Test("sub024")).ok = ((new com.ibm.icu.math.BigDecimal(
04993: "10000e+9")).subtract(new com.ibm.icu.math.BigDecimal(
04994: "700")).toString()).equals("9999999999300");
04995:
04996: (new Test("sub025")).ok = ((new com.ibm.icu.math.BigDecimal(
04997: "10000e+9")).subtract(new com.ibm.icu.math.BigDecimal(
04998: "7000")).toString()).equals("9999999993000");
04999:
05000: (new Test("sub026")).ok = ((new com.ibm.icu.math.BigDecimal(
05001: "10000e+9")).subtract(new com.ibm.icu.math.BigDecimal(
05002: "70000")).toString()).equals("9999999930000");
05003:
05004: (new Test("sub027")).ok = ((new com.ibm.icu.math.BigDecimal(
05005: "10000e+9")).subtract(new com.ibm.icu.math.BigDecimal(
05006: "700000")).toString()).equals("9999999300000");
05007:
05008: // MC
05009: (new Test("sub030")).ok = ((new com.ibm.icu.math.BigDecimal(
05010: "10000e+9")).subtract(new com.ibm.icu.math.BigDecimal(
05011: "70000"), mcdef).toString()).equals("9.9999999E+12");
05012:
05013: (new Test("sub031")).ok = ((new com.ibm.icu.math.BigDecimal(
05014: "10000e+9")).subtract(new com.ibm.icu.math.BigDecimal(
05015: "70000"), mc6).toString()).equals("1.00000E+13");
05016:
05017: // some of the next group are really constructor tests
05018: (new Test("sub040")).ok = ((new com.ibm.icu.math.BigDecimal(
05019: "00.0"))
05020: .subtract(new com.ibm.icu.math.BigDecimal("0.0"))
05021: .toString()).equals("0.0");
05022: (new Test("sub041")).ok = ((new com.ibm.icu.math.BigDecimal(
05023: "00.0")).subtract(new com.ibm.icu.math.BigDecimal(
05024: "0.00")).toString()).equals("0.00");
05025: (new Test("sub042")).ok = ((new com.ibm.icu.math.BigDecimal(
05026: "0.00")).subtract(new com.ibm.icu.math.BigDecimal(
05027: "00.0")).toString()).equals("0.00");
05028: (new Test("sub043")).ok = ((new com.ibm.icu.math.BigDecimal(
05029: "00.0")).subtract(new com.ibm.icu.math.BigDecimal(
05030: "0.00"), mcdef).toString()).equals("0");
05031: (new Test("sub044")).ok = ((new com.ibm.icu.math.BigDecimal(
05032: "0.00")).subtract(new com.ibm.icu.math.BigDecimal(
05033: "00.0"), mcdef).toString()).equals("0");
05034: (new Test("sub045")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
05035: .subtract(new com.ibm.icu.math.BigDecimal(".3"), mcdef)
05036: .toString()).equals("2.7");
05037: (new Test("sub046")).ok = ((new com.ibm.icu.math.BigDecimal(
05038: "3.")).subtract(new com.ibm.icu.math.BigDecimal(".3"),
05039: mcdef).toString()).equals("2.7");
05040: (new Test("sub047")).ok = ((new com.ibm.icu.math.BigDecimal(
05041: "3.0")).subtract(new com.ibm.icu.math.BigDecimal(".3"),
05042: mcdef).toString()).equals("2.7");
05043: (new Test("sub048")).ok = ((new com.ibm.icu.math.BigDecimal(
05044: "3.00")).subtract(
05045: new com.ibm.icu.math.BigDecimal(".3"), mcdef)
05046: .toString()).equals("2.70");
05047: (new Test("sub049")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
05048: .subtract(new com.ibm.icu.math.BigDecimal("3"), mcdef)
05049: .toString()).equals("0");
05050: (new Test("sub050")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
05051: .subtract(new com.ibm.icu.math.BigDecimal("+3"), mcdef)
05052: .toString()).equals("0");
05053: (new Test("sub051")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
05054: .subtract(new com.ibm.icu.math.BigDecimal("-3"), mcdef)
05055: .toString()).equals("6");
05056: (new Test("sub052")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
05057: .subtract(new com.ibm.icu.math.BigDecimal(".3"))
05058: .toString()).equals("2.7");
05059: (new Test("sub053")).ok = ((new com.ibm.icu.math.BigDecimal(
05060: "3.")).subtract(new com.ibm.icu.math.BigDecimal(".3"))
05061: .toString()).equals("2.7");
05062: (new Test("sub054")).ok = ((new com.ibm.icu.math.BigDecimal(
05063: "3.0")).subtract(new com.ibm.icu.math.BigDecimal(".3"))
05064: .toString()).equals("2.7");
05065: (new Test("sub055")).ok = ((new com.ibm.icu.math.BigDecimal(
05066: "3.00"))
05067: .subtract(new com.ibm.icu.math.BigDecimal(".3"))
05068: .toString()).equals("2.70");
05069: (new Test("sub056")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
05070: .subtract(new com.ibm.icu.math.BigDecimal("3"))
05071: .toString()).equals("0");
05072: (new Test("sub057")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
05073: .subtract(new com.ibm.icu.math.BigDecimal("+3"))
05074: .toString()).equals("0");
05075: (new Test("sub058")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
05076: .subtract(new com.ibm.icu.math.BigDecimal("-3"))
05077: .toString()).equals("6");
05078:
05079: // the above all from add; massaged and extended. Now some new ones...
05080: // [particularly important for comparisons]
05081: // NB: -1E-7 below were non-exponents pre-ANSI
05082: (new Test("sub080")).ok = ("-1E-7")
05083: .equals((new com.ibm.icu.math.BigDecimal("10.23456784"))
05084: .subtract(
05085: new com.ibm.icu.math.BigDecimal(
05086: "10.23456789"), mcdef)
05087: .toString());
05088: (new Test("sub081")).ok = "0"
05089: .equals((new com.ibm.icu.math.BigDecimal("10.23456785"))
05090: .subtract(
05091: new com.ibm.icu.math.BigDecimal(
05092: "10.23456789"), mcdef)
05093: .toString());
05094: (new Test("sub082")).ok = "0"
05095: .equals((new com.ibm.icu.math.BigDecimal("10.23456786"))
05096: .subtract(
05097: new com.ibm.icu.math.BigDecimal(
05098: "10.23456789"), mcdef)
05099: .toString());
05100: (new Test("sub083")).ok = "0"
05101: .equals((new com.ibm.icu.math.BigDecimal("10.23456787"))
05102: .subtract(
05103: new com.ibm.icu.math.BigDecimal(
05104: "10.23456789"), mcdef)
05105: .toString());
05106: (new Test("sub084")).ok = "0"
05107: .equals((new com.ibm.icu.math.BigDecimal("10.23456788"))
05108: .subtract(
05109: new com.ibm.icu.math.BigDecimal(
05110: "10.23456789"), mcdef)
05111: .toString());
05112: (new Test("sub085")).ok = "0"
05113: .equals((new com.ibm.icu.math.BigDecimal("10.23456789"))
05114: .subtract(
05115: new com.ibm.icu.math.BigDecimal(
05116: "10.23456789"), mcdef)
05117: .toString());
05118: (new Test("sub086")).ok = "0"
05119: .equals((new com.ibm.icu.math.BigDecimal("10.23456790"))
05120: .subtract(
05121: new com.ibm.icu.math.BigDecimal(
05122: "10.23456789"), mcdef)
05123: .toString());
05124: (new Test("sub087")).ok = "0"
05125: .equals((new com.ibm.icu.math.BigDecimal("10.23456791"))
05126: .subtract(
05127: new com.ibm.icu.math.BigDecimal(
05128: "10.23456789"), mcdef)
05129: .toString());
05130: (new Test("sub088")).ok = "0"
05131: .equals((new com.ibm.icu.math.BigDecimal("10.23456792"))
05132: .subtract(
05133: new com.ibm.icu.math.BigDecimal(
05134: "10.23456789"), mcdef)
05135: .toString());
05136: (new Test("sub089")).ok = "0"
05137: .equals((new com.ibm.icu.math.BigDecimal("10.23456793"))
05138: .subtract(
05139: new com.ibm.icu.math.BigDecimal(
05140: "10.23456789"), mcdef)
05141: .toString());
05142: (new Test("sub090")).ok = "0"
05143: .equals((new com.ibm.icu.math.BigDecimal("10.23456794"))
05144: .subtract(
05145: new com.ibm.icu.math.BigDecimal(
05146: "10.23456789"), mcdef)
05147: .toString());
05148: (new Test("sub091")).ok = ("-1E-7")
05149: .equals((new com.ibm.icu.math.BigDecimal("10.23456781"))
05150: .subtract(
05151: new com.ibm.icu.math.BigDecimal(
05152: "10.23456786"), mcdef)
05153: .toString());
05154: (new Test("sub092")).ok = ("-1E-7")
05155: .equals((new com.ibm.icu.math.BigDecimal("10.23456782"))
05156: .subtract(
05157: new com.ibm.icu.math.BigDecimal(
05158: "10.23456786"), mcdef)
05159: .toString());
05160: (new Test("sub093")).ok = ("-1E-7")
05161: .equals((new com.ibm.icu.math.BigDecimal("10.23456783"))
05162: .subtract(
05163: new com.ibm.icu.math.BigDecimal(
05164: "10.23456786"), mcdef)
05165: .toString());
05166: (new Test("sub094")).ok = ("-1E-7")
05167: .equals((new com.ibm.icu.math.BigDecimal("10.23456784"))
05168: .subtract(
05169: new com.ibm.icu.math.BigDecimal(
05170: "10.23456786"), mcdef)
05171: .toString());
05172: (new Test("sub095")).ok = "0"
05173: .equals((new com.ibm.icu.math.BigDecimal("10.23456785"))
05174: .subtract(
05175: new com.ibm.icu.math.BigDecimal(
05176: "10.23456786"), mcdef)
05177: .toString());
05178: (new Test("sub096")).ok = "0"
05179: .equals((new com.ibm.icu.math.BigDecimal("10.23456786"))
05180: .subtract(
05181: new com.ibm.icu.math.BigDecimal(
05182: "10.23456786"), mcdef)
05183: .toString());
05184: (new Test("sub097")).ok = "0"
05185: .equals((new com.ibm.icu.math.BigDecimal("10.23456787"))
05186: .subtract(
05187: new com.ibm.icu.math.BigDecimal(
05188: "10.23456786"), mcdef)
05189: .toString());
05190: (new Test("sub098")).ok = "0"
05191: .equals((new com.ibm.icu.math.BigDecimal("10.23456788"))
05192: .subtract(
05193: new com.ibm.icu.math.BigDecimal(
05194: "10.23456786"), mcdef)
05195: .toString());
05196: (new Test("sub099")).ok = "0"
05197: .equals((new com.ibm.icu.math.BigDecimal("10.23456789"))
05198: .subtract(
05199: new com.ibm.icu.math.BigDecimal(
05200: "10.23456786"), mcdef)
05201: .toString());
05202: (new Test("sub100")).ok = "0"
05203: .equals((new com.ibm.icu.math.BigDecimal("10.23456790"))
05204: .subtract(
05205: new com.ibm.icu.math.BigDecimal(
05206: "10.23456786"), mcdef)
05207: .toString());
05208: (new Test("sub101")).ok = "0"
05209: .equals((new com.ibm.icu.math.BigDecimal("10.23456791"))
05210: .subtract(
05211: new com.ibm.icu.math.BigDecimal(
05212: "10.23456786"), mcdef)
05213: .toString());
05214: (new Test("sub102")).ok = "0"
05215: .equals(com.ibm.icu.math.BigDecimal.ONE.subtract(
05216: new com.ibm.icu.math.BigDecimal("0.999999999"),
05217: mcdef).toString());
05218: (new Test("sub103")).ok = "0"
05219: .equals((new com.ibm.icu.math.BigDecimal("0.999999999"))
05220: .subtract(com.ibm.icu.math.BigDecimal.ONE,
05221: mcdef).toString());
05222:
05223: alhs = new com.ibm.icu.math.BigDecimal("12345678900000");
05224: arhs = new com.ibm.icu.math.BigDecimal("9999999999999");
05225: (new Test("sub110")).ok = (alhs.subtract(arhs, mc3).toString())
05226: .equals("2.3E+12");
05227: (new Test("sub111")).ok = (arhs.subtract(alhs, mc3).toString())
05228: .equals("-2.3E+12");
05229: (new Test("sub112")).ok = (alhs.subtract(arhs).toString())
05230: .equals("2345678900001");
05231: (new Test("sub113")).ok = (arhs.subtract(alhs).toString())
05232: .equals("-2345678900001");
05233:
05234: // additional scaled arithmetic tests [0.97 problem]
05235: (new Test("sub120")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05236: .subtract(new com.ibm.icu.math.BigDecimal(".1"))
05237: .toString()).equals("-0.1");
05238: (new Test("sub121")).ok = ((new com.ibm.icu.math.BigDecimal(
05239: "00")).subtract(new com.ibm.icu.math.BigDecimal(
05240: ".97983")).toString()).equals("-0.97983");
05241: (new Test("sub122")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05242: .subtract(new com.ibm.icu.math.BigDecimal(".9"))
05243: .toString()).equals("-0.9");
05244: (new Test("sub123")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05245: .subtract(new com.ibm.icu.math.BigDecimal("0.102"))
05246: .toString()).equals("-0.102");
05247: (new Test("sub124")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05248: .subtract(new com.ibm.icu.math.BigDecimal(".4"))
05249: .toString()).equals("-0.4");
05250: (new Test("sub125")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05251: .subtract(new com.ibm.icu.math.BigDecimal(".307"))
05252: .toString()).equals("-0.307");
05253: (new Test("sub126")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05254: .subtract(new com.ibm.icu.math.BigDecimal(".43822"))
05255: .toString()).equals("-0.43822");
05256: (new Test("sub127")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05257: .subtract(new com.ibm.icu.math.BigDecimal(".911"))
05258: .toString()).equals("-0.911");
05259: (new Test("sub128")).ok = ((new com.ibm.icu.math.BigDecimal(
05260: ".0")).subtract(new com.ibm.icu.math.BigDecimal(".02"))
05261: .toString()).equals("-0.02");
05262: (new Test("sub129")).ok = ((new com.ibm.icu.math.BigDecimal(
05263: "00"))
05264: .subtract(new com.ibm.icu.math.BigDecimal(".392"))
05265: .toString()).equals("-0.392");
05266: (new Test("sub130")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05267: .subtract(new com.ibm.icu.math.BigDecimal(".26"))
05268: .toString()).equals("-0.26");
05269: (new Test("sub131")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05270: .subtract(new com.ibm.icu.math.BigDecimal("0.51"))
05271: .toString()).equals("-0.51");
05272: (new Test("sub132")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05273: .subtract(new com.ibm.icu.math.BigDecimal(".2234"))
05274: .toString()).equals("-0.2234");
05275: (new Test("sub133")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05276: .subtract(new com.ibm.icu.math.BigDecimal(".2"))
05277: .toString()).equals("-0.2");
05278: (new Test("sub134")).ok = ((new com.ibm.icu.math.BigDecimal(
05279: ".0"))
05280: .subtract(new com.ibm.icu.math.BigDecimal(".0008"))
05281: .toString()).equals("-0.0008");
05282: // 0. on left
05283: (new Test("sub140")).ok = ((new com.ibm.icu.math.BigDecimal(
05284: "0.0"))
05285: .subtract(new com.ibm.icu.math.BigDecimal("-.1"))
05286: .toString()).equals("0.1");
05287: (new Test("sub141")).ok = ((new com.ibm.icu.math.BigDecimal(
05288: "0.00")).subtract(new com.ibm.icu.math.BigDecimal(
05289: "-.97983")).toString()).equals("0.97983");
05290: (new Test("sub142")).ok = ((new com.ibm.icu.math.BigDecimal(
05291: "0.0"))
05292: .subtract(new com.ibm.icu.math.BigDecimal("-.9"))
05293: .toString()).equals("0.9");
05294: (new Test("sub143")).ok = ((new com.ibm.icu.math.BigDecimal(
05295: "0.0")).subtract(new com.ibm.icu.math.BigDecimal(
05296: "-0.102")).toString()).equals("0.102");
05297: (new Test("sub144")).ok = ((new com.ibm.icu.math.BigDecimal(
05298: "0.0"))
05299: .subtract(new com.ibm.icu.math.BigDecimal("-.4"))
05300: .toString()).equals("0.4");
05301: (new Test("sub145")).ok = ((new com.ibm.icu.math.BigDecimal(
05302: "0.0")).subtract(new com.ibm.icu.math.BigDecimal(
05303: "-.307")).toString()).equals("0.307");
05304: (new Test("sub146")).ok = ((new com.ibm.icu.math.BigDecimal(
05305: "0.0")).subtract(new com.ibm.icu.math.BigDecimal(
05306: "-.43822")).toString()).equals("0.43822");
05307: (new Test("sub147")).ok = ((new com.ibm.icu.math.BigDecimal(
05308: "0.0")).subtract(new com.ibm.icu.math.BigDecimal(
05309: "-.911")).toString()).equals("0.911");
05310: (new Test("sub148")).ok = ((new com.ibm.icu.math.BigDecimal(
05311: "0.0"))
05312: .subtract(new com.ibm.icu.math.BigDecimal("-.02"))
05313: .toString()).equals("0.02");
05314: (new Test("sub149")).ok = ((new com.ibm.icu.math.BigDecimal(
05315: "0.00")).subtract(new com.ibm.icu.math.BigDecimal(
05316: "-.392")).toString()).equals("0.392");
05317: (new Test("sub150")).ok = ((new com.ibm.icu.math.BigDecimal(
05318: "0.0"))
05319: .subtract(new com.ibm.icu.math.BigDecimal("-.26"))
05320: .toString()).equals("0.26");
05321: (new Test("sub151")).ok = ((new com.ibm.icu.math.BigDecimal(
05322: "0.0")).subtract(new com.ibm.icu.math.BigDecimal(
05323: "-0.51")).toString()).equals("0.51");
05324: (new Test("sub152")).ok = ((new com.ibm.icu.math.BigDecimal(
05325: "0.0")).subtract(new com.ibm.icu.math.BigDecimal(
05326: "-.2234")).toString()).equals("0.2234");
05327: (new Test("sub153")).ok = ((new com.ibm.icu.math.BigDecimal(
05328: "0.0"))
05329: .subtract(new com.ibm.icu.math.BigDecimal("-.2"))
05330: .toString()).equals("0.2");
05331: (new Test("sub154")).ok = ((new com.ibm.icu.math.BigDecimal(
05332: "0.0")).subtract(new com.ibm.icu.math.BigDecimal(
05333: "-.0008")).toString()).equals("0.0008");
05334: // negatives of same
05335: (new Test("sub160")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05336: .subtract(new com.ibm.icu.math.BigDecimal("-.1"))
05337: .toString()).equals("0.1");
05338: (new Test("sub161")).ok = ((new com.ibm.icu.math.BigDecimal(
05339: "00")).subtract(new com.ibm.icu.math.BigDecimal(
05340: "-.97983")).toString()).equals("0.97983");
05341: (new Test("sub162")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05342: .subtract(new com.ibm.icu.math.BigDecimal("-.9"))
05343: .toString()).equals("0.9");
05344: (new Test("sub163")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05345: .subtract(new com.ibm.icu.math.BigDecimal("-0.102"))
05346: .toString()).equals("0.102");
05347: (new Test("sub164")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05348: .subtract(new com.ibm.icu.math.BigDecimal("-.4"))
05349: .toString()).equals("0.4");
05350: (new Test("sub165")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05351: .subtract(new com.ibm.icu.math.BigDecimal("-.307"))
05352: .toString()).equals("0.307");
05353: (new Test("sub166")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05354: .subtract(new com.ibm.icu.math.BigDecimal("-.43822"))
05355: .toString()).equals("0.43822");
05356: (new Test("sub167")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05357: .subtract(new com.ibm.icu.math.BigDecimal("-.911"))
05358: .toString()).equals("0.911");
05359: (new Test("sub168")).ok = ((new com.ibm.icu.math.BigDecimal(
05360: ".0"))
05361: .subtract(new com.ibm.icu.math.BigDecimal("-.02"))
05362: .toString()).equals("0.02");
05363: (new Test("sub169")).ok = ((new com.ibm.icu.math.BigDecimal(
05364: "00"))
05365: .subtract(new com.ibm.icu.math.BigDecimal("-.392"))
05366: .toString()).equals("0.392");
05367: (new Test("sub170")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05368: .subtract(new com.ibm.icu.math.BigDecimal("-.26"))
05369: .toString()).equals("0.26");
05370: (new Test("sub171")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05371: .subtract(new com.ibm.icu.math.BigDecimal("-0.51"))
05372: .toString()).equals("0.51");
05373: (new Test("sub172")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05374: .subtract(new com.ibm.icu.math.BigDecimal("-.2234"))
05375: .toString()).equals("0.2234");
05376: (new Test("sub173")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05377: .subtract(new com.ibm.icu.math.BigDecimal("-.2"))
05378: .toString()).equals("0.2");
05379: (new Test("sub174")).ok = ((new com.ibm.icu.math.BigDecimal(
05380: ".0")).subtract(new com.ibm.icu.math.BigDecimal(
05381: "-.0008")).toString()).equals("0.0008");
05382:
05383: // more fixed, LHS swaps [really same as testcases under add]
05384: (new Test("sub180")).ok = ((new com.ibm.icu.math.BigDecimal(
05385: "-56267E-10")).subtract(zero).toString())
05386: .equals("-0.0000056267");
05387: (new Test("sub181")).ok = ((new com.ibm.icu.math.BigDecimal(
05388: "-56267E-5")).subtract(zero).toString())
05389: .equals("-0.56267");
05390: (new Test("sub182")).ok = ((new com.ibm.icu.math.BigDecimal(
05391: "-56267E-2")).subtract(zero).toString())
05392: .equals("-562.67");
05393: (new Test("sub183")).ok = ((new com.ibm.icu.math.BigDecimal(
05394: "-56267E-1")).subtract(zero).toString())
05395: .equals("-5626.7");
05396: (new Test("sub185")).ok = ((new com.ibm.icu.math.BigDecimal(
05397: "-56267E-0")).subtract(zero).toString())
05398: .equals("-56267");
05399:
05400: try {
05401: checknull: do {
05402: ten.subtract((com.ibm.icu.math.BigDecimal) null);
05403: flag = false;
05404: } while (false);
05405: } catch (java.lang.NullPointerException $83) {
05406: flag = true;
05407: }/*checknull*/
05408: (new Test("sub200")).ok = flag;
05409: try {
05410: checknull2: do {
05411: ten.subtract(ten, (com.ibm.icu.math.MathContext) null);
05412: flag = false;
05413: } while (false);
05414: } catch (java.lang.NullPointerException $84) {
05415: flag = true;
05416: }/*checknull2*/
05417: (new Test("sub201")).ok = flag;
05418:
05419: try {
05420: checkdigits: do {
05421: com.ibm.icu.math.BigDecimal.ONE.subtract(tenlong, mcld);
05422: flag = false;
05423: } while (false);
05424: } catch (java.lang.ArithmeticException $85) {
05425: ae = $85;
05426: flag = (ae.getMessage()).equals("Too many digits:" + " "
05427: + tenlong.toString());
05428: }/*checkdigits*/
05429: (new Test("sub202")).ok = flag;
05430: try {
05431: checkdigits: do {
05432: tenlong.subtract(com.ibm.icu.math.BigDecimal.ONE, mcld);
05433: flag = false;
05434: } while (false);
05435: } catch (java.lang.ArithmeticException $86) {
05436: ae = $86;
05437: flag = (ae.getMessage()).equals("Too many digits:" + " "
05438: + tenlong.toString());
05439: }/*checkdigits*/
05440: (new Test("sub203")).ok = flag;
05441: summary("subtract");
05442: }
05443:
05444: /* ----------------------------------------------------------------- */
05445:
05446: /* ----------------------------------------------------------------- */
05447: /* Other methods */
05448: /* ----------------------------------------------------------------- */
05449:
05450: /** Test the <code>BigDecimal.byteValue()</code> method. */
05451:
05452: public void diagbyteValue() {
05453: boolean flag = false;
05454: java.lang.String v = null;
05455: java.lang.ArithmeticException ae = null;
05456: java.lang.String badstrings[];
05457: int i = 0;
05458: java.lang.String norm = null;
05459:
05460: (new Test("byv001")).ok = ((((byte) -128))) == ((new com.ibm.icu.math.BigDecimal(
05461: "-128")).byteValue());
05462: (new Test("byv002")).ok = ((0)) == ((new com.ibm.icu.math.BigDecimal(
05463: "0")).byteValue());
05464: (new Test("byv003")).ok = ((1)) == ((new com.ibm.icu.math.BigDecimal(
05465: "1")).byteValue());
05466: (new Test("byv004")).ok = ((99)) == ((new com.ibm.icu.math.BigDecimal(
05467: "99")).byteValue());
05468: (new Test("byv005")).ok = ((127)) == ((new com.ibm.icu.math.BigDecimal(
05469: "127")).byteValue());
05470: (new Test("byv006")).ok = ((-128)) == ((new com.ibm.icu.math.BigDecimal(
05471: "128")).byteValue());
05472: (new Test("byv007")).ok = ((-127)) == ((new com.ibm.icu.math.BigDecimal(
05473: "129")).byteValue());
05474: (new Test("byv008")).ok = ((127)) == ((new com.ibm.icu.math.BigDecimal(
05475: "-129")).byteValue());
05476: (new Test("byv009")).ok = ((126)) == ((new com.ibm.icu.math.BigDecimal(
05477: "-130")).byteValue());
05478: (new Test("byv010")).ok = ((bmax)) == ((new com.ibm.icu.math.BigDecimal(
05479: bmax)).byteValue());
05480: (new Test("byv011")).ok = ((bmin)) == ((new com.ibm.icu.math.BigDecimal(
05481: bmin)).byteValue());
05482: (new Test("byv012")).ok = ((bneg)) == ((new com.ibm.icu.math.BigDecimal(
05483: bneg)).byteValue());
05484: (new Test("byv013")).ok = ((bzer)) == ((new com.ibm.icu.math.BigDecimal(
05485: bzer)).byteValue());
05486: (new Test("byv014")).ok = ((bpos)) == ((new com.ibm.icu.math.BigDecimal(
05487: bpos)).byteValue());
05488: (new Test("byv015")).ok = ((bmin)) == ((new com.ibm.icu.math.BigDecimal(
05489: bmax + 1)).byteValue());
05490: (new Test("byv016")).ok = ((bmax)) == ((new com.ibm.icu.math.BigDecimal(
05491: bmin - 1)).byteValue());
05492:
05493: (new Test("byv021")).ok = ((((byte) -128))) == ((new com.ibm.icu.math.BigDecimal(
05494: "-128")).byteValueExact());
05495: (new Test("byv022")).ok = ((0)) == ((new com.ibm.icu.math.BigDecimal(
05496: "0")).byteValueExact());
05497: (new Test("byv023")).ok = ((1)) == ((new com.ibm.icu.math.BigDecimal(
05498: "1")).byteValueExact());
05499: (new Test("byv024")).ok = ((99)) == ((new com.ibm.icu.math.BigDecimal(
05500: "99")).byteValueExact());
05501: (new Test("byv025")).ok = ((127)) == ((new com.ibm.icu.math.BigDecimal(
05502: "127")).byteValueExact());
05503: (new Test("byv026")).ok = ((bmax)) == ((new com.ibm.icu.math.BigDecimal(
05504: bmax)).byteValueExact());
05505: (new Test("byv027")).ok = ((bmin)) == ((new com.ibm.icu.math.BigDecimal(
05506: bmin)).byteValueExact());
05507: (new Test("byv028")).ok = ((bneg)) == ((new com.ibm.icu.math.BigDecimal(
05508: bneg)).byteValueExact());
05509: (new Test("byv029")).ok = ((bzer)) == ((new com.ibm.icu.math.BigDecimal(
05510: bzer)).byteValueExact());
05511: (new Test("byv030")).ok = ((bpos)) == ((new com.ibm.icu.math.BigDecimal(
05512: bpos)).byteValueExact());
05513: try {
05514: v = "-129";
05515: (new com.ibm.icu.math.BigDecimal(v)).byteValueExact();
05516: flag = false;
05517: } catch (java.lang.ArithmeticException $87) {
05518: ae = $87;
05519: flag = (ae.getMessage()).equals("Conversion overflow:"
05520: + " " + v);
05521: }
05522: (new Test("byv100")).ok = flag;
05523: try {
05524: v = "128";
05525: (new com.ibm.icu.math.BigDecimal(v)).byteValueExact();
05526: flag = false;
05527: } catch (java.lang.ArithmeticException $88) {
05528: ae = $88;
05529: flag = (ae.getMessage()).equals("Conversion overflow:"
05530: + " " + v);
05531: }
05532: (new Test("byv101")).ok = flag;
05533: try {
05534: v = "1.5";
05535: (new com.ibm.icu.math.BigDecimal(v)).byteValueExact();
05536: flag = false;
05537: } catch (java.lang.ArithmeticException $89) {
05538: ae = $89;
05539: flag = (ae.getMessage()).equals("Decimal part non-zero:"
05540: + " " + v);
05541: }
05542: (new Test("byv102")).ok = flag;
05543:
05544: badstrings = new java.lang.String[] {
05545: "1234",
05546: (new com.ibm.icu.math.BigDecimal(bmax)).add(one)
05547: .toString(),
05548: (new com.ibm.icu.math.BigDecimal(bmin)).subtract(one)
05549: .toString(),
05550: "170",
05551: "270",
05552: "370",
05553: "470",
05554: "570",
05555: "670",
05556: "770",
05557: "870",
05558: "970",
05559: "-170",
05560: "-270",
05561: "-370",
05562: "-470",
05563: "-570",
05564: "-670",
05565: "-770",
05566: "-870",
05567: "-970",
05568: (new com.ibm.icu.math.BigDecimal(bmin)).multiply(two)
05569: .toString(),
05570: (new com.ibm.icu.math.BigDecimal(bmax)).multiply(two)
05571: .toString(),
05572: (new com.ibm.icu.math.BigDecimal(bmin)).multiply(ten)
05573: .toString(),
05574: (new com.ibm.icu.math.BigDecimal(bmax)).multiply(ten)
05575: .toString(), "-1234" }; // 220
05576: // 221
05577: // 222
05578: // 223
05579: // 224
05580: // 225
05581: // 226
05582: // 227
05583: // 228
05584: // 229
05585: // 230
05586: // 231
05587: // 232
05588: // 233
05589: // 234
05590: // 235
05591: // 236
05592: // 237
05593: // 238
05594: // 239
05595: // 240
05596: // 241
05597: // 242
05598: // 243
05599: // 244
05600: // 245
05601: {
05602: int $90 = badstrings.length;
05603: i = 0;
05604: i: for (; $90 > 0; $90--, i++) {
05605: try {
05606: v = badstrings[i];
05607: (new com.ibm.icu.math.BigDecimal(v))
05608: .byteValueExact();
05609: flag = false;
05610: } catch (java.lang.ArithmeticException $91) {
05611: ae = $91;
05612: norm = (new com.ibm.icu.math.BigDecimal(v))
05613: .toString();
05614: flag = (ae.getMessage())
05615: .equals("Conversion overflow:" + " " + norm);
05616: }
05617: (new Test("byv" + (220 + i))).ok = flag;
05618: }
05619: }/*i*/
05620:
05621: summary("byteValue+");
05622: }
05623:
05624: /* ----------------------------------------------------------------- */
05625:
05626: /** Test the {@link com.ibm.icu.math.BigDecimal#compareTo(java.lang.Object)} method. */
05627:
05628: public void diagcomparetoObj() {
05629: boolean flag = false;
05630: com.ibm.icu.math.BigDecimal d;
05631: com.ibm.icu.math.BigDecimal long1;
05632: com.ibm.icu.math.BigDecimal long2;
05633:
05634: d = new com.ibm.icu.math.BigDecimal(17);
05635: (new Test("cto001")).ok = (d
05636: .compareTo((java.lang.Object) (new com.ibm.icu.math.BigDecimal(
05637: 66)))) == (-1);
05638: (new Test("cto002")).ok = (d
05639: .compareTo((java.lang.Object) ((new com.ibm.icu.math.BigDecimal(
05640: 10)).add(new com.ibm.icu.math.BigDecimal(7))))) == 0;
05641: (new Test("cto003")).ok = (d
05642: .compareTo((java.lang.Object) (new com.ibm.icu.math.BigDecimal(
05643: 10)))) == 1;
05644: long1 = new com.ibm.icu.math.BigDecimal("12345678903");
05645: long2 = new com.ibm.icu.math.BigDecimal("12345678900");
05646: (new Test("cto004")).ok = (long1
05647: .compareTo((java.lang.Object) long2)) == 1;
05648: (new Test("cto005")).ok = (long2
05649: .compareTo((java.lang.Object) long1)) == (-1);
05650: (new Test("cto006")).ok = (long2
05651: .compareTo((java.lang.Object) long2)) == 0;
05652: try {
05653: d.compareTo((java.lang.Object) null);
05654: flag = false;
05655: } catch (java.lang.NullPointerException $92) {
05656: flag = true; // should get here
05657: }
05658: (new Test("cto101")).ok = flag;
05659: try {
05660: d.compareTo((java.lang.Object) "foo");
05661: flag = false;
05662: } catch (java.lang.ClassCastException $93) {
05663: flag = true; // should get here
05664: }
05665: (new Test("cto102")).ok = flag;
05666: summary("compareTo(Obj)");
05667: }
05668:
05669: /* ----------------------------------------------------------------- */
05670:
05671: /** Test the {@link com.ibm.icu.math.BigDecimal#doubleValue} method. */
05672:
05673: public void diagdoublevalue() {
05674: java.lang.String val;
05675: // 1999.03.07 Infinities no longer errors
05676: val = "-1";
05677: (new Test("dov001")).ok = ((new com.ibm.icu.math.BigDecimal(val))
05678: .doubleValue()) == ((new java.lang.Double(val))
05679: .doubleValue());
05680: val = "-0.1";
05681: (new Test("dov002")).ok = ((new com.ibm.icu.math.BigDecimal(val))
05682: .doubleValue()) == ((new java.lang.Double(val))
05683: .doubleValue());
05684: val = "0";
05685: (new Test("dov003")).ok = ((new com.ibm.icu.math.BigDecimal(val))
05686: .doubleValue()) == ((new java.lang.Double(val))
05687: .doubleValue());
05688: val = "0.1";
05689: (new Test("dov004")).ok = ((new com.ibm.icu.math.BigDecimal(val))
05690: .doubleValue()) == ((new java.lang.Double(val))
05691: .doubleValue());
05692: val = "1";
05693: (new Test("dov005")).ok = ((new com.ibm.icu.math.BigDecimal(val))
05694: .doubleValue()) == ((new java.lang.Double(val))
05695: .doubleValue());
05696: val = "1e1000";
05697: (new Test("dov006")).ok = ((new com.ibm.icu.math.BigDecimal(val))
05698: .doubleValue()) == java.lang.Double.POSITIVE_INFINITY;
05699: val = "-1e1000";
05700: (new Test("dov007")).ok = ((new com.ibm.icu.math.BigDecimal(val))
05701: .doubleValue()) == java.lang.Double.NEGATIVE_INFINITY;
05702: summary("doubleValue");
05703: }
05704:
05705: /* ----------------------------------------------------------------- */
05706:
05707: /** Test the {@link com.ibm.icu.math.BigDecimal#equals} method. */
05708:
05709: public void diagequals() {
05710: com.ibm.icu.math.BigDecimal d;
05711: d = new com.ibm.icu.math.BigDecimal(17);
05712: (new Test("equ001")).ok = (!(d.equals((java.lang.Object) null)));
05713: (new Test("equ002")).ok = (!(d.equals((java.lang.Object) "foo")));
05714: (new Test("equ003")).ok = (!(d
05715: .equals((java.lang.Object) (new com.ibm.icu.math.BigDecimal(
05716: 66)))));
05717: (new Test("equ004")).ok = d.equals((java.lang.Object) d);
05718: (new Test("equ005")).ok = d
05719: .equals((java.lang.Object) ((new com.ibm.icu.math.BigDecimal(
05720: 10)).add(new com.ibm.icu.math.BigDecimal(7))));
05721: summary("equals");
05722: }
05723:
05724: /* ----------------------------------------------------------------- */
05725:
05726: /** Test the {@link com.ibm.icu.math.BigDecimal#floatValue} method. */
05727:
05728: public void diagfloatvalue() {
05729: java.lang.String val;
05730: // 1999.03.07 Infinities no longer errors
05731: val = "-1";
05732: (new Test("flv001")).ok = ((new com.ibm.icu.math.BigDecimal(val))
05733: .floatValue()) == ((new java.lang.Float(val))
05734: .floatValue());
05735: val = "-0.1";
05736: (new Test("flv002")).ok = ((new com.ibm.icu.math.BigDecimal(val))
05737: .floatValue()) == ((new java.lang.Float(val))
05738: .floatValue());
05739: val = "0";
05740: (new Test("flv003")).ok = ((new com.ibm.icu.math.BigDecimal(val))
05741: .floatValue()) == ((new java.lang.Float(val))
05742: .floatValue());
05743: val = "0.1";
05744: (new Test("flv004")).ok = ((new com.ibm.icu.math.BigDecimal(val))
05745: .floatValue()) == ((new java.lang.Float(val))
05746: .floatValue());
05747: val = "1";
05748: (new Test("flv005")).ok = ((new com.ibm.icu.math.BigDecimal(val))
05749: .floatValue()) == ((new java.lang.Float(val))
05750: .floatValue());
05751: val = "1e200";
05752: (new Test("flv006")).ok = ((new com.ibm.icu.math.BigDecimal(val))
05753: .floatValue()) == java.lang.Float.POSITIVE_INFINITY;
05754: val = "-1e200";
05755: (new Test("flv007")).ok = ((new com.ibm.icu.math.BigDecimal(val))
05756: .floatValue()) == java.lang.Float.NEGATIVE_INFINITY;
05757: val = "1e1000";
05758: (new Test("flv008")).ok = ((new com.ibm.icu.math.BigDecimal(val))
05759: .floatValue()) == java.lang.Float.POSITIVE_INFINITY;
05760: val = "-1e1000";
05761: (new Test("flv009")).ok = ((new com.ibm.icu.math.BigDecimal(val))
05762: .floatValue()) == java.lang.Float.NEGATIVE_INFINITY;
05763: summary("floatValue");
05764: }
05765:
05766: /* ----------------------------------------------------------------- */
05767:
05768: /** Test the {@link com.ibm.icu.math.BigDecimal#format} method. */
05769:
05770: public void diagformat() {
05771: boolean flag = false;
05772: int eng;
05773: int sci;
05774: com.ibm.icu.math.BigDecimal d04;
05775: com.ibm.icu.math.BigDecimal d05;
05776: com.ibm.icu.math.BigDecimal d06;
05777: com.ibm.icu.math.BigDecimal d15;
05778: java.lang.IllegalArgumentException iae = null;
05779: com.ibm.icu.math.BigDecimal d050;
05780: com.ibm.icu.math.BigDecimal d150;
05781: com.ibm.icu.math.BigDecimal m050;
05782: com.ibm.icu.math.BigDecimal m150;
05783: com.ibm.icu.math.BigDecimal d051;
05784: com.ibm.icu.math.BigDecimal d151;
05785: com.ibm.icu.math.BigDecimal d000;
05786: com.ibm.icu.math.BigDecimal d500;
05787: java.lang.ArithmeticException ae = null;
05788: // 1999.02.09 now only two signatures for format(), so some tests below
05789: // may now be redundant
05790:
05791: (new Test("for001")).ok = ((new com.ibm.icu.math.BigDecimal(
05792: "12.3")).format(-1, -1)).equals("12.3");
05793: (new Test("for002")).ok = ((new com.ibm.icu.math.BigDecimal(
05794: "-12.73")).format(-1, -1)).equals("-12.73");
05795: (new Test("for003")).ok = ((new com.ibm.icu.math.BigDecimal(
05796: "0.000")).format(-1, -1)).equals("0.000");
05797: (new Test("for004")).ok = ((new com.ibm.icu.math.BigDecimal(
05798: "3E+3")).format(-1, -1)).equals("3000");
05799: (new Test("for005")).ok = ((new com.ibm.icu.math.BigDecimal("3"))
05800: .format(4, -1)).equals(" 3");
05801: (new Test("for006")).ok = ((new com.ibm.icu.math.BigDecimal(
05802: "1.73")).format(4, 0)).equals(" 2");
05803: (new Test("for007")).ok = ((new com.ibm.icu.math.BigDecimal(
05804: "1.73")).format(4, 1)).equals(" 1.7");
05805: (new Test("for008")).ok = ((new com.ibm.icu.math.BigDecimal(
05806: "1.75")).format(4, 1)).equals(" 1.8");
05807: (new Test("for009")).ok = ((new com.ibm.icu.math.BigDecimal(
05808: "0.5")).format(4, 1)).equals(" 0.5");
05809: (new Test("for010")).ok = ((new com.ibm.icu.math.BigDecimal(
05810: "0.05")).format(4, 1)).equals(" 0.1");
05811: (new Test("for011")).ok = ((new com.ibm.icu.math.BigDecimal(
05812: "0.04")).format(4, 1)).equals(" 0.0");
05813: (new Test("for012")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05814: .format(4, 0)).equals(" 0");
05815: (new Test("for013")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05816: .format(4, 1)).equals(" 0.0");
05817: (new Test("for014")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05818: .format(4, 2)).equals(" 0.00");
05819: (new Test("for015")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05820: .format(4, 3)).equals(" 0.000");
05821: (new Test("for016")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
05822: .format(4, 4)).equals(" 0.0000");
05823: (new Test("for017")).ok = ((new com.ibm.icu.math.BigDecimal(
05824: "0.005")).format(4, 0)).equals(" 0");
05825: (new Test("for018")).ok = ((new com.ibm.icu.math.BigDecimal(
05826: "0.005")).format(4, 1)).equals(" 0.0");
05827: (new Test("for019")).ok = ((new com.ibm.icu.math.BigDecimal(
05828: "0.005")).format(4, 2)).equals(" 0.01");
05829: (new Test("for020")).ok = ((new com.ibm.icu.math.BigDecimal(
05830: "0.004")).format(4, 2)).equals(" 0.00");
05831: (new Test("for021")).ok = ((new com.ibm.icu.math.BigDecimal(
05832: "0.005")).format(4, 3)).equals(" 0.005");
05833: (new Test("for022")).ok = ((new com.ibm.icu.math.BigDecimal(
05834: "0.005")).format(4, 4)).equals(" 0.0050");
05835:
05836: (new Test("for023")).ok = ((new com.ibm.icu.math.BigDecimal(
05837: "1.73")).format(4, 2)).equals(" 1.73");
05838: (new Test("for024")).ok = ((new com.ibm.icu.math.BigDecimal(
05839: "1.73")).format(4, 3)).equals(" 1.730");
05840: (new Test("for025")).ok = ((new com.ibm.icu.math.BigDecimal(
05841: "-.76")).format(4, 1)).equals(" -0.8");
05842: (new Test("for026")).ok = ((new com.ibm.icu.math.BigDecimal(
05843: "-12.73")).format(-1, 4)).equals("-12.7300");
05844:
05845: (new Test("for027")).ok = ((new com.ibm.icu.math.BigDecimal(
05846: "3.03")).format(4, -1)).equals(" 3.03");
05847: (new Test("for028")).ok = ((new com.ibm.icu.math.BigDecimal(
05848: "3.03")).format(4, 1)).equals(" 3.0");
05849: (new Test("for029")).ok = ((new com.ibm.icu.math.BigDecimal(
05850: "3.03")).format(4, -1, 3, -1, -1, -1))
05851: .equals(" 3.03 ");
05852: (new Test("for030")).ok = ((new com.ibm.icu.math.BigDecimal(
05853: "3.03")).format(-1, -1, 3, -1, -1, -1))
05854: .equals("3.03 ");
05855: (new Test("for031")).ok = ((new com.ibm.icu.math.BigDecimal(
05856: "12345.73")).format(-1, -1, -1, 4, -1, -1))
05857: .equals("1.234573E+4");
05858: (new Test("for032")).ok = ((new com.ibm.icu.math.BigDecimal(
05859: "12345.73")).format(-1, -1, -1, 5, -1, -1))
05860: .equals("12345.73");
05861: (new Test("for033")).ok = ((new com.ibm.icu.math.BigDecimal(
05862: "12345.73")).format(-1, -1, -1, 6, -1, -1))
05863: .equals("12345.73");
05864:
05865: (new Test("for034")).ok = ((new com.ibm.icu.math.BigDecimal(
05866: "12345.73")).format(-1, 8, -1, 3, -1, -1))
05867: .equals("1.23457300E+4");
05868: (new Test("for035")).ok = ((new com.ibm.icu.math.BigDecimal(
05869: "12345.73")).format(-1, 7, -1, 3, -1, -1))
05870: .equals("1.2345730E+4");
05871: (new Test("for036")).ok = ((new com.ibm.icu.math.BigDecimal(
05872: "12345.73")).format(-1, 6, -1, 3, -1, -1))
05873: .equals("1.234573E+4");
05874: (new Test("for037")).ok = ((new com.ibm.icu.math.BigDecimal(
05875: "12345.73")).format(-1, 5, -1, 3, -1, -1))
05876: .equals("1.23457E+4");
05877: (new Test("for038")).ok = ((new com.ibm.icu.math.BigDecimal(
05878: "12345.73")).format(-1, 4, -1, 3, -1, -1))
05879: .equals("1.2346E+4");
05880: (new Test("for039")).ok = ((new com.ibm.icu.math.BigDecimal(
05881: "12345.73")).format(-1, 3, -1, 3, -1, -1))
05882: .equals("1.235E+4");
05883: (new Test("for040")).ok = ((new com.ibm.icu.math.BigDecimal(
05884: "12345.73")).format(-1, 2, -1, 3, -1, -1))
05885: .equals("1.23E+4");
05886: (new Test("for041")).ok = ((new com.ibm.icu.math.BigDecimal(
05887: "12345.73")).format(-1, 1, -1, 3, -1, -1))
05888: .equals("1.2E+4");
05889: (new Test("for042")).ok = ((new com.ibm.icu.math.BigDecimal(
05890: "12345.73")).format(-1, 0, -1, 3, -1, -1))
05891: .equals("1E+4");
05892:
05893: (new Test("for043")).ok = ((new com.ibm.icu.math.BigDecimal(
05894: "99999.99")).format(-1, 6, -1, 3, -1, -1))
05895: .equals("9.999999E+4");
05896: (new Test("for044")).ok = ((new com.ibm.icu.math.BigDecimal(
05897: "99999.99")).format(-1, 5, -1, 3, -1, -1))
05898: .equals("1.00000E+5");
05899: (new Test("for045")).ok = ((new com.ibm.icu.math.BigDecimal(
05900: "99999.99")).format(-1, 2, -1, 3, -1, -1))
05901: .equals("1.00E+5");
05902: (new Test("for046")).ok = ((new com.ibm.icu.math.BigDecimal(
05903: "99999.99")).format(-1, 0, -1, 3, -1, -1))
05904: .equals("1E+5");
05905: (new Test("for047")).ok = ((new com.ibm.icu.math.BigDecimal(
05906: "99999.99")).format(3, 0, -1, 3, -1, -1))
05907: .equals(" 1E+5");
05908:
05909: (new Test("for048")).ok = ((new com.ibm.icu.math.BigDecimal(
05910: "12345.73")).format(-1, -1, 2, 2, -1, -1))
05911: .equals("1.234573E+04");
05912: (new Test("for049")).ok = ((new com.ibm.icu.math.BigDecimal(
05913: "12345.73")).format(-1, 3, -1, 0, -1, -1))
05914: .equals("1.235E+4");
05915: (new Test("for050")).ok = ((new com.ibm.icu.math.BigDecimal(
05916: "1.234573")).format(-1, 3, -1, 0, -1, -1))
05917: .equals("1.235");
05918: (new Test("for051")).ok = ((new com.ibm.icu.math.BigDecimal(
05919: "123.45")).format(-1, 3, 2, 0, -1, -1))
05920: .equals("1.235E+02");
05921:
05922: (new Test("for052")).ok = ((new com.ibm.icu.math.BigDecimal(
05923: "0.444")).format(-1, 0)).equals("0");
05924: (new Test("for053")).ok = ((new com.ibm.icu.math.BigDecimal(
05925: "-0.444")).format(-1, 0)).equals("0");
05926: (new Test("for054")).ok = ((new com.ibm.icu.math.BigDecimal(
05927: "0.4")).format(-1, 0)).equals("0");
05928: (new Test("for055")).ok = ((new com.ibm.icu.math.BigDecimal(
05929: "-0.4")).format(-1, 0)).equals("0");
05930:
05931: eng = com.ibm.icu.math.MathContext.ENGINEERING;
05932: sci = com.ibm.icu.math.MathContext.SCIENTIFIC;
05933: (new Test("for060")).ok = ((new com.ibm.icu.math.BigDecimal(
05934: "1234.5")).format(-1, 3, 2, 0, eng, -1))
05935: .equals("1.235E+03");
05936: (new Test("for061")).ok = ((new com.ibm.icu.math.BigDecimal(
05937: "12345")).format(-1, 3, 3, 0, eng, -1))
05938: .equals("12.345E+003");
05939: (new Test("for062")).ok = ((new com.ibm.icu.math.BigDecimal(
05940: "12345")).format(-1, 3, 3, 0, sci, -1))
05941: .equals("1.235E+004");
05942: (new Test("for063")).ok = ((new com.ibm.icu.math.BigDecimal(
05943: "1234.5")).format(4, 3, 2, 0, eng, -1))
05944: .equals(" 1.235E+03");
05945: (new Test("for064")).ok = ((new com.ibm.icu.math.BigDecimal(
05946: "12345")).format(5, 3, 3, 0, eng, -1))
05947: .equals(" 12.345E+003");
05948: (new Test("for065")).ok = ((new com.ibm.icu.math.BigDecimal(
05949: "12345")).format(6, 3, 3, 0, sci, -1))
05950: .equals(" 1.235E+004");
05951:
05952: (new Test("for066")).ok = ((new com.ibm.icu.math.BigDecimal(
05953: "1.2345")).format(-1, 3, 2, 0, -1, -1))
05954: .equals("1.235 ");
05955: (new Test("for067")).ok = ((new com.ibm.icu.math.BigDecimal(
05956: "12345.73")).format(-1, -1, 3, 6, -1, -1))
05957: .equals("12345.73 ");
05958: (new Test("for068")).ok = ((new com.ibm.icu.math.BigDecimal(
05959: "12345e+5")).format(-1, 0)).equals("1234500000");
05960: (new Test("for069")).ok = ((new com.ibm.icu.math.BigDecimal(
05961: "12345e+5")).format(-1, 1)).equals("1234500000.0");
05962: (new Test("for070")).ok = ((new com.ibm.icu.math.BigDecimal(
05963: "12345e+5")).format(-1, 2)).equals("1234500000.00");
05964: (new Test("for071")).ok = ((new com.ibm.icu.math.BigDecimal(
05965: "12345e+5")).format(-1, 3)).equals("1234500000.000");
05966: (new Test("for072")).ok = ((new com.ibm.icu.math.BigDecimal(
05967: "12345e+5")).format(-1, 4)).equals("1234500000.0000");
05968:
05969: // some from ANSI Dallas [Nov 1998]
05970: (new Test("for073")).ok = ((new com.ibm.icu.math.BigDecimal(
05971: "99.999")).format(-1, 2, -1, 2, -1, -1))
05972: .equals("100.00");
05973: (new Test("for074")).ok = ((new com.ibm.icu.math.BigDecimal(
05974: "0.99999")).format(-1, 4, 2, 2, -1, -1))
05975: .equals("1.0000 ");
05976:
05977: // try some rounding modes [default ROUND_HALF_UP widely tested above]
05978: // the first few also tests that defaults are accepted for the others
05979: d04 = new com.ibm.icu.math.BigDecimal("0.04");
05980: d05 = new com.ibm.icu.math.BigDecimal("0.05");
05981: d06 = new com.ibm.icu.math.BigDecimal("0.06");
05982: d15 = new com.ibm.icu.math.BigDecimal("0.15");
05983: (new Test("for080")).ok = (d05.format(-1, 1)).equals("0.1");
05984: (new Test("for081")).ok = (d05.format(-1, 1, -1, -1, -1,
05985: com.ibm.icu.math.MathContext.ROUND_HALF_UP))
05986: .equals("0.1");
05987: (new Test("for082")).ok = (d05.format(-1, 1, -1, -1, -1, -1))
05988: .equals("0.1");
05989: (new Test("for083")).ok = (d05.format(-1, -1, -1, -1, -1, -1))
05990: .equals("0.05");
05991: (new Test("for084")).ok = (d05.format(-1, -1)).equals("0.05");
05992: try {
05993: d05.format(-1, -1, -1, -1, -1, 30); // bad mode
05994: flag = false; // shouldn't get here
05995: } catch (java.lang.IllegalArgumentException $94) {
05996: iae = $94;
05997: flag = (iae.getMessage())
05998: .equals("Bad argument 6 to format: 30");
05999: }
06000: (new Test("for085")).ok = flag;
06001:
06002: (new Test("for090")).ok = (d04.format(-1, 1)).equals("0.0");
06003: (new Test("for091")).ok = (d06.format(-1, 1)).equals("0.1");
06004: (new Test("for092")).ok = (d04.format(-1, 1, -1, -1, -1,
06005: com.ibm.icu.math.MathContext.ROUND_HALF_DOWN))
06006: .equals("0.0");
06007: (new Test("for093")).ok = (d05.format(-1, 1, -1, -1, -1,
06008: com.ibm.icu.math.MathContext.ROUND_HALF_DOWN))
06009: .equals("0.0");
06010: (new Test("for094")).ok = (d06.format(-1, 1, -1, -1, -1,
06011: com.ibm.icu.math.MathContext.ROUND_HALF_DOWN))
06012: .equals("0.1");
06013:
06014: (new Test("for095")).ok = (d04.format(-1, 1, -1, -1, -1,
06015: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN))
06016: .equals("0.0");
06017: (new Test("for096")).ok = (d05.format(-1, 1, -1, -1, -1,
06018: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN))
06019: .equals("0.0");
06020: (new Test("for097")).ok = (d06.format(-1, 1, -1, -1, -1,
06021: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN))
06022: .equals("0.1");
06023: (new Test("for098")).ok = (d15.format(-1, 1, -1, -1, -1,
06024: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN))
06025: .equals("0.2");
06026: d050 = new com.ibm.icu.math.BigDecimal("0.050");
06027: d150 = new com.ibm.icu.math.BigDecimal("0.150");
06028: (new Test("for099")).ok = (d050.format(-1, 1, -1, -1, -1,
06029: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN))
06030: .equals("0.0");
06031: (new Test("for100")).ok = (d150.format(-1, 1, -1, -1, -1,
06032: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN))
06033: .equals("0.2");
06034: m050 = new com.ibm.icu.math.BigDecimal("-0.050");
06035: m150 = new com.ibm.icu.math.BigDecimal("-0.150");
06036: (new Test("for101")).ok = (m050.format(-1, 1, -1, -1, -1,
06037: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN))
06038: .equals("0.0");
06039: (new Test("for102")).ok = (m150.format(-1, 1, -1, -1, -1,
06040: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN))
06041: .equals("-0.2");
06042: d051 = new com.ibm.icu.math.BigDecimal("0.051");
06043: d151 = new com.ibm.icu.math.BigDecimal("0.151");
06044: (new Test("for103")).ok = (d051.format(-1, 1, -1, -1, -1,
06045: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN))
06046: .equals("0.1");
06047: (new Test("for104")).ok = (d151.format(-1, 1, -1, -1, -1,
06048: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN))
06049: .equals("0.2");
06050:
06051: (new Test("for105")).ok = (m050.format(-1, 1, -1, -1, -1,
06052: com.ibm.icu.math.MathContext.ROUND_CEILING))
06053: .equals("0.0");
06054: (new Test("for106")).ok = (m150.format(-1, 1, -1, -1, -1,
06055: com.ibm.icu.math.MathContext.ROUND_CEILING))
06056: .equals("-0.1");
06057: (new Test("for107")).ok = (d050.format(-1, 1, -1, -1, -1,
06058: com.ibm.icu.math.MathContext.ROUND_CEILING))
06059: .equals("0.1");
06060: (new Test("for108")).ok = (d150.format(-1, 1, -1, -1, -1,
06061: com.ibm.icu.math.MathContext.ROUND_CEILING))
06062: .equals("0.2");
06063:
06064: (new Test("for109")).ok = (m050.format(-1, 1, -1, -1, -1,
06065: com.ibm.icu.math.MathContext.ROUND_FLOOR))
06066: .equals("-0.1");
06067: (new Test("for110")).ok = (m150.format(-1, 1, -1, -1, -1,
06068: com.ibm.icu.math.MathContext.ROUND_FLOOR))
06069: .equals("-0.2");
06070: (new Test("for111")).ok = (d050.format(-1, 1, -1, -1, -1,
06071: com.ibm.icu.math.MathContext.ROUND_FLOOR))
06072: .equals("0.0");
06073: (new Test("for112")).ok = (d150.format(-1, 1, -1, -1, -1,
06074: com.ibm.icu.math.MathContext.ROUND_FLOOR))
06075: .equals("0.1");
06076:
06077: (new Test("for113")).ok = (m050.format(-1, 1, -1, -1, -1,
06078: com.ibm.icu.math.MathContext.ROUND_UP)).equals("-0.1");
06079: (new Test("for114")).ok = (m150.format(-1, 1, -1, -1, -1,
06080: com.ibm.icu.math.MathContext.ROUND_UP)).equals("-0.2");
06081: (new Test("for115")).ok = (d050.format(-1, 1, -1, -1, -1,
06082: com.ibm.icu.math.MathContext.ROUND_UP)).equals("0.1");
06083: (new Test("for116")).ok = (d150.format(-1, 1, -1, -1, -1,
06084: com.ibm.icu.math.MathContext.ROUND_UP)).equals("0.2");
06085:
06086: (new Test("for117")).ok = (m050.format(-1, 1, -1, -1, -1,
06087: com.ibm.icu.math.MathContext.ROUND_DOWN)).equals("0.0");
06088: (new Test("for118")).ok = (m150.format(-1, 1, -1, -1, -1,
06089: com.ibm.icu.math.MathContext.ROUND_DOWN))
06090: .equals("-0.1");
06091: (new Test("for119")).ok = (d050.format(-1, 1, -1, -1, -1,
06092: com.ibm.icu.math.MathContext.ROUND_DOWN)).equals("0.0");
06093: (new Test("for120")).ok = (d150.format(-1, 1, -1, -1, -1,
06094: com.ibm.icu.math.MathContext.ROUND_DOWN)).equals("0.1");
06095:
06096: d000 = new com.ibm.icu.math.BigDecimal("0.000");
06097: d500 = new com.ibm.icu.math.BigDecimal("0.500");
06098: (new Test("for121")).ok = (d000.format(-1, 1, -1, -1, -1,
06099: com.ibm.icu.math.MathContext.ROUND_UNNECESSARY))
06100: .equals("0.0");
06101: (new Test("for122")).ok = (d000.format(-1, 2, -1, -1, -1,
06102: com.ibm.icu.math.MathContext.ROUND_UNNECESSARY))
06103: .equals("0.00");
06104: (new Test("for123")).ok = (d000.format(-1, 3, -1, -1, -1,
06105: com.ibm.icu.math.MathContext.ROUND_UNNECESSARY))
06106: .equals("0.000");
06107: try { // this should trap..
06108: d050.format(-1, 1, -1, -1, -1,
06109: com.ibm.icu.math.MathContext.ROUND_UNNECESSARY);
06110: flag = false;
06111: } catch (java.lang.ArithmeticException $95) {
06112: ae = $95;
06113: flag = (ae.getMessage()).equals("Rounding necessary");
06114: }
06115: (new Test("for124")).ok = flag;
06116: (new Test("for125")).ok = (d050.format(-1, 2, -1, -1, -1,
06117: com.ibm.icu.math.MathContext.ROUND_UNNECESSARY))
06118: .equals("0.05");
06119: (new Test("for126")).ok = (d050.format(-1, 3, -1, -1, -1,
06120: com.ibm.icu.math.MathContext.ROUND_UNNECESSARY))
06121: .equals("0.050");
06122: (new Test("for127")).ok = (d500.format(-1, 1, -1, -1, -1,
06123: com.ibm.icu.math.MathContext.ROUND_UNNECESSARY))
06124: .equals("0.5");
06125: (new Test("for128")).ok = (d500.format(-1, 2, -1, -1, -1,
06126: com.ibm.icu.math.MathContext.ROUND_UNNECESSARY))
06127: .equals("0.50");
06128: (new Test("for129")).ok = (d500.format(-1, 3, -1, -1, -1,
06129: com.ibm.icu.math.MathContext.ROUND_UNNECESSARY))
06130: .equals("0.500");
06131:
06132: // bad negs --
06133: try {
06134: d050.format(-2, -1, -1, -1, -1, -1);
06135: flag = false;
06136: } catch (java.lang.IllegalArgumentException $96) {
06137: flag = true;
06138: }
06139: (new Test("for131")).ok = flag;
06140: try {
06141: d050.format(-1, -2, -1, -1, -1, -1);
06142: flag = false;
06143: } catch (java.lang.IllegalArgumentException $97) {
06144: flag = true;
06145: }
06146: (new Test("for132")).ok = flag;
06147: try {
06148: d050.format(-1, -1, -2, -1, -1, -1);
06149: flag = false;
06150: } catch (java.lang.IllegalArgumentException $98) {
06151: flag = true;
06152: }
06153: (new Test("for133")).ok = flag;
06154: try {
06155: d050.format(-1, -1, -1, -2, -1, -1);
06156: flag = false;
06157: } catch (java.lang.IllegalArgumentException $99) {
06158: flag = true;
06159: }
06160: (new Test("for134")).ok = flag;
06161: try {
06162: d050.format(-1, -1, -1, -1, -2, -1);
06163: flag = false;
06164: } catch (java.lang.IllegalArgumentException $100) {
06165: flag = true;
06166: }
06167: (new Test("for135")).ok = flag;
06168: try {
06169: d050.format(-1, -1, -1, -1, -1, -2);
06170: flag = false;
06171: } catch (java.lang.IllegalArgumentException $101) {
06172: flag = true;
06173: }
06174: (new Test("for136")).ok = flag;
06175:
06176: summary("format");
06177: }
06178:
06179: /* ----------------------------------------------------------------- */
06180:
06181: /** Test the {@link com.ibm.icu.math.BigDecimal#hashCode} method. */
06182:
06183: public void diaghashcode() {
06184: java.lang.String hs;
06185: com.ibm.icu.math.BigDecimal d;
06186: hs = "27827817";
06187: d = new com.ibm.icu.math.BigDecimal(hs);
06188: (new Test("has001")).ok = (d.hashCode()) == (hs.hashCode());
06189: hs = "1.265E+200";
06190: d = new com.ibm.icu.math.BigDecimal(hs);
06191: (new Test("has002")).ok = (d.hashCode()) == (hs.hashCode());
06192: hs = "126.5E+200";
06193: d = new com.ibm.icu.math.BigDecimal(hs);
06194: (new Test("has003")).ok = (d.hashCode()) != (hs.hashCode());
06195: summary("hashCode");
06196: }
06197:
06198: /* ----------------------------------------------------------------- */
06199:
06200: /** Test the {@link com.ibm.icu.math.BigDecimal#intValue} method. */
06201:
06202: public void diagintvalue() {
06203: boolean flag = false;
06204: java.lang.String v = null;
06205: java.lang.ArithmeticException ae = null;
06206: java.lang.String badstrings[];
06207: int i = 0;
06208: java.lang.String norm = null;
06209: com.ibm.icu.math.BigDecimal dimax;
06210: com.ibm.icu.math.BigDecimal num = null;
06211: com.ibm.icu.math.BigDecimal dv = null;
06212: com.ibm.icu.math.BigDecimal dimin;
06213:
06214: // intValue --
06215:
06216: (new Test("inv001")).ok = imin == ((new com.ibm.icu.math.BigDecimal(
06217: imin)).intValue());
06218: (new Test("inv002")).ok = ((99)) == ((new com.ibm.icu.math.BigDecimal(
06219: "99")).intValue());
06220: (new Test("inv003")).ok = ((1)) == ((new com.ibm.icu.math.BigDecimal(
06221: "1")).intValue());
06222: (new Test("inv004")).ok = ((0)) == ((new com.ibm.icu.math.BigDecimal(
06223: "0")).intValue());
06224: (new Test("inv005")).ok = ((-1)) == ((new com.ibm.icu.math.BigDecimal(
06225: "-1")).intValue());
06226: (new Test("inv006")).ok = ((-99)) == ((new com.ibm.icu.math.BigDecimal(
06227: "-99")).intValue());
06228: (new Test("inv007")).ok = imax == ((new com.ibm.icu.math.BigDecimal(
06229: imax)).intValue());
06230: (new Test("inv008")).ok = ((5)) == ((new com.ibm.icu.math.BigDecimal(
06231: "5.0")).intValue());
06232: (new Test("inv009")).ok = ((5)) == ((new com.ibm.icu.math.BigDecimal(
06233: "5.3")).intValue());
06234: (new Test("inv010")).ok = ((5)) == ((new com.ibm.icu.math.BigDecimal(
06235: "5.5")).intValue());
06236: (new Test("inv011")).ok = ((5)) == ((new com.ibm.icu.math.BigDecimal(
06237: "5.7")).intValue());
06238: (new Test("inv012")).ok = ((5)) == ((new com.ibm.icu.math.BigDecimal(
06239: "5.9")).intValue());
06240: (new Test("inv013")).ok = ((-5)) == ((new com.ibm.icu.math.BigDecimal(
06241: "-5.0")).intValue());
06242: (new Test("inv014")).ok = ((-5)) == ((new com.ibm.icu.math.BigDecimal(
06243: "-5.3")).intValue());
06244: (new Test("inv015")).ok = ((-5)) == ((new com.ibm.icu.math.BigDecimal(
06245: "-5.5")).intValue());
06246: (new Test("inv016")).ok = ((-5)) == ((new com.ibm.icu.math.BigDecimal(
06247: "-5.7")).intValue());
06248: (new Test("inv017")).ok = ((-5)) == ((new com.ibm.icu.math.BigDecimal(
06249: "-5.9")).intValue());
06250: (new Test("inv018")).ok = ((new com.ibm.icu.math.BigDecimal(
06251: "88888888888")).intValue()) == (-1305424328); // ugh
06252: (new Test("inv019")).ok = ((new com.ibm.icu.math.BigDecimal(
06253: "-88888888888")).intValue()) == 1305424328; // ugh
06254: (new Test("inv020")).ok = ((imin)) == ((new com.ibm.icu.math.BigDecimal(
06255: (((long) imax)) + 1)).intValue());
06256: (new Test("inv021")).ok = ((imax)) == ((new com.ibm.icu.math.BigDecimal(
06257: (((long) imin)) - 1)).intValue());
06258:
06259: // intValueExact --
06260:
06261: (new Test("inv101")).ok = imin == ((new com.ibm.icu.math.BigDecimal(
06262: imin)).intValueExact());
06263: (new Test("inv102")).ok = ((99)) == ((new com.ibm.icu.math.BigDecimal(
06264: "99")).intValue());
06265: (new Test("inv103")).ok = ((1)) == ((new com.ibm.icu.math.BigDecimal(
06266: "1")).intValue());
06267: (new Test("inv104")).ok = ((0)) == ((new com.ibm.icu.math.BigDecimal(
06268: "0")).intValue());
06269: (new Test("inv105")).ok = ((-1)) == ((new com.ibm.icu.math.BigDecimal(
06270: "-1")).intValue());
06271: (new Test("inv106")).ok = ((-99)) == ((new com.ibm.icu.math.BigDecimal(
06272: "-99")).intValue());
06273: (new Test("inv107")).ok = imax == ((new com.ibm.icu.math.BigDecimal(
06274: imax)).intValue());
06275: (new Test("inv108")).ok = ((5)) == ((new com.ibm.icu.math.BigDecimal(
06276: "5.0")).intValue());
06277: (new Test("inv109")).ok = ((-5)) == ((new com.ibm.icu.math.BigDecimal(
06278: "-5.0")).intValue());
06279: (new Test("inv110")).ok = imax == ((new com.ibm.icu.math.BigDecimal(
06280: imax)).intValueExact());
06281:
06282: try {
06283: v = "-88588688888";
06284: (new com.ibm.icu.math.BigDecimal(v)).intValueExact();
06285: flag = false;
06286: } catch (java.lang.ArithmeticException $102) {
06287: ae = $102;
06288: flag = (ae.getMessage()).equals("Conversion overflow:"
06289: + " " + v);
06290: }
06291: (new Test("inv200")).ok = flag;
06292:
06293: // this one could raise either overflow or bad decimal part
06294: try {
06295: v = "88088818888.00001";
06296: (new com.ibm.icu.math.BigDecimal(v)).intValueExact();
06297: flag = false;
06298: } catch (java.lang.ArithmeticException $103) {
06299: flag = true;
06300: }
06301: (new Test("inv201")).ok = flag;
06302:
06303: // 1999.10.28: the testcases marked '*' failed
06304: badstrings = new java.lang.String[] {
06305: "12345678901",
06306: (new com.ibm.icu.math.BigDecimal(imax)).add(one)
06307: .toString(),
06308: (new com.ibm.icu.math.BigDecimal(imin)).subtract(one)
06309: .toString(),
06310: "3731367293",
06311: "4731367293",
06312: "5731367293",
06313: "6731367293",
06314: "7731367293",
06315: "8731367293",
06316: "9731367293",
06317: "-3731367293",
06318: "-4731367293",
06319: "-5731367293",
06320: "-6731367293",
06321: "-7731367293",
06322: "-8731367293",
06323: "-9731367293",
06324: (new com.ibm.icu.math.BigDecimal(imin)).multiply(two)
06325: .toString(),
06326: (new com.ibm.icu.math.BigDecimal(imax)).multiply(two)
06327: .toString(),
06328: (new com.ibm.icu.math.BigDecimal(imin)).multiply(ten)
06329: .toString(),
06330: (new com.ibm.icu.math.BigDecimal(imax)).multiply(ten)
06331: .toString(), "4731367293", "4831367293",
06332: "4931367293", "5031367293", "5131367293", "5231367293",
06333: "5331367293", "5431367293", "5531367293", "5631367293",
06334: "5731367293", "5831367293", "5931367293", "6031367293",
06335: "6131367293", "6231367293", "6331367293", "6431367293",
06336: "6531367293", "6631367293", "6731367293", "2200000000",
06337: "2300000000", "2400000000", "2500000000", "2600000000",
06338: "2700000000", "2800000000", "2900000000",
06339: "-2200000000", "-2300000000", "-2400000000",
06340: "-2500000000", "-2600000000", "-2700000000",
06341: "-2800000000", "-2900000000", "25E+8", "-25E+8",
06342: "-12345678901" }; // 220
06343: // 221
06344: // 222
06345: // 223
06346: // 224
06347: // 225 *
06348: // 226
06349: // 227
06350: // 228
06351: // 229 *
06352: // 230
06353: // 231
06354: // 232 *
06355: // 233
06356: // 234
06357: // 235
06358: // 236 *
06359: // 237
06360: // 238
06361: // 239
06362: // 240
06363: // 241
06364: // 242 *
06365: // 243 *
06366: // 244 *
06367: // 245 *
06368: // 246 *
06369: // 247 *
06370: // 248 *
06371: // 249 *
06372: // 250 *
06373: // 251 *
06374: // 252 *
06375: // 253 *
06376: // 254 *
06377: // 255 *
06378: // 256 *
06379: // 257 *
06380: // 258 *
06381: // 259
06382: // 260
06383: // 261
06384: // 262
06385: // 263
06386: // 264
06387: // 265
06388: // 266
06389: // 267
06390: // 268
06391: // 269
06392: // 270
06393: // 271
06394: // 272
06395: // 273
06396: // 274
06397: // 275
06398: // 276
06399: // 277
06400: // 278
06401: // 279
06402: // 280
06403: {
06404: int $104 = badstrings.length;
06405: i = 0;
06406: i: for (; $104 > 0; $104--, i++) {
06407: try {
06408: v = badstrings[i];
06409: (new com.ibm.icu.math.BigDecimal(v))
06410: .intValueExact();
06411: flag = false;
06412: } catch (java.lang.ArithmeticException $105) {
06413: ae = $105;
06414: norm = (new com.ibm.icu.math.BigDecimal(v))
06415: .toString();
06416: flag = (ae.getMessage())
06417: .equals("Conversion overflow:" + " " + norm);
06418: }
06419: (new Test("inv" + (220 + i))).ok = flag;
06420: }
06421: }/*i*/
06422:
06423: // now slip in some single bits...
06424: dimax = new com.ibm.icu.math.BigDecimal(imax);
06425: {
06426: i = 0;
06427: i: for (; i <= 49; i++) {
06428: try {
06429: num = two.pow(new com.ibm.icu.math.BigDecimal(i),
06430: mc50);
06431: dv = dimax.add(num, mc50);
06432: dv.intValueExact();
06433: flag = false;
06434: } catch (java.lang.ArithmeticException $106) {
06435: ae = $106;
06436: norm = dv.toString();
06437: flag = (ae.getMessage())
06438: .equals("Conversion overflow:" + " " + norm);
06439: }
06440: (new Test("inv" + (300 + i))).ok = flag;
06441: }
06442: }/*i*/
06443: dimin = new com.ibm.icu.math.BigDecimal(imin);
06444: {
06445: i = 50;
06446: i: for (; i <= 99; i++) {
06447: try {
06448: num = two.pow(new com.ibm.icu.math.BigDecimal(i),
06449: mc50);
06450: dv = dimin.subtract(num, mc50);
06451: dv.intValueExact();
06452: flag = false;
06453: } catch (java.lang.ArithmeticException $107) {
06454: ae = $107;
06455: norm = dv.toString();
06456: flag = (ae.getMessage())
06457: .equals("Conversion overflow:" + " " + norm);
06458: }
06459: (new Test("inv" + (300 + i))).ok = flag;
06460: }
06461: }/*i*/
06462:
06463: // the following should all raise bad-decimal-part exceptions
06464: badstrings = new java.lang.String[] { "0.09", "0.9", "0.01",
06465: "0.1", "-0.01", "-0.1", "1.01", "-1.01", "-1.1",
06466: "-111.111", "+111.111", "1.09", "1.05", "1.04", "1.99",
06467: "1.9", "1.5", "1.4", "-1.09", "-1.05", "-1.04",
06468: "-1.99", "-1.9", "-1.5", "-1.4", "1E-1000", "-1E-1000",
06469: "11E-1", "1.5" }; // 400-403
06470: // 404-407
06471: // 408-411
06472: // 412-416
06473: // 417-420
06474: // 421-424
06475: // 425-428
06476:
06477: {
06478: int $108 = badstrings.length;
06479: i = 0;
06480: i: for (; $108 > 0; $108--, i++) {
06481: try {
06482: v = badstrings[i];
06483: (new com.ibm.icu.math.BigDecimal(v))
06484: .intValueExact();
06485: flag = false;
06486: } catch (java.lang.ArithmeticException $109) {
06487: ae = $109;
06488: norm = (new com.ibm.icu.math.BigDecimal(v))
06489: .toString();
06490: flag = (ae.getMessage())
06491: .equals("Decimal part non-zero:" + " "
06492: + norm);
06493: }
06494: (new Test("inv" + (400 + i))).ok = flag;
06495: }
06496: }/*i*/
06497:
06498: summary("intValue+");
06499: }
06500:
06501: /* ----------------------------------------------------------------- */
06502:
06503: /** Test the {@link com.ibm.icu.math.BigDecimal#longValue} method. */
06504:
06505: public void diaglongvalue() {
06506: boolean flag = false;
06507: java.lang.String v = null;
06508: java.lang.ArithmeticException ae = null;
06509: java.lang.String badstrings[];
06510: int i = 0;
06511: java.lang.String norm = null;
06512: com.ibm.icu.math.BigDecimal dlmax;
06513: com.ibm.icu.math.BigDecimal num = null;
06514: com.ibm.icu.math.BigDecimal dv = null;
06515: com.ibm.icu.math.BigDecimal dlmin;
06516:
06517: // longValue --
06518:
06519: (new Test("lov001")).ok = lmin == ((new com.ibm.icu.math.BigDecimal(
06520: lmin)).longValue());
06521: (new Test("lov002")).ok = (((long) 99)) == ((new com.ibm.icu.math.BigDecimal(
06522: "99")).longValue());
06523: (new Test("lov003")).ok = (((long) 1)) == ((new com.ibm.icu.math.BigDecimal(
06524: "1")).longValue());
06525: (new Test("lov004")).ok = (((long) 0)) == ((new com.ibm.icu.math.BigDecimal(
06526: "0")).longValue());
06527: (new Test("lov005")).ok = (((long) -1)) == ((new com.ibm.icu.math.BigDecimal(
06528: "-1")).longValue());
06529: (new Test("lov006")).ok = (((long) -99)) == ((new com.ibm.icu.math.BigDecimal(
06530: "-99")).longValue());
06531: (new Test("lov007")).ok = lmax == ((new com.ibm.icu.math.BigDecimal(
06532: lmax)).longValue());
06533: (new Test("lov008")).ok = (((long) 5)) == ((new com.ibm.icu.math.BigDecimal(
06534: "5.0")).longValue());
06535: (new Test("lov009")).ok = (((long) 5)) == ((new com.ibm.icu.math.BigDecimal(
06536: "5.3")).longValue());
06537: (new Test("lov010")).ok = (((long) 5)) == ((new com.ibm.icu.math.BigDecimal(
06538: "5.5")).longValue());
06539: (new Test("lov011")).ok = (((long) 5)) == ((new com.ibm.icu.math.BigDecimal(
06540: "5.7")).longValue());
06541: (new Test("lov012")).ok = (((long) 5)) == ((new com.ibm.icu.math.BigDecimal(
06542: "5.9")).longValue());
06543: (new Test("lov013")).ok = (((long) -5)) == ((new com.ibm.icu.math.BigDecimal(
06544: "-5.0")).longValue());
06545: (new Test("lov014")).ok = (((long) -5)) == ((new com.ibm.icu.math.BigDecimal(
06546: "-5.3")).longValue());
06547: (new Test("lov015")).ok = (((long) -5)) == ((new com.ibm.icu.math.BigDecimal(
06548: "-5.5")).longValue());
06549: (new Test("lov016")).ok = (((long) -5)) == ((new com.ibm.icu.math.BigDecimal(
06550: "-5.7")).longValue());
06551: (new Test("lov017")).ok = (((long) -5)) == ((new com.ibm.icu.math.BigDecimal(
06552: "-5.9")).longValue());
06553: (new Test("lov018")).ok = ((new com.ibm.icu.math.BigDecimal(
06554: "888888888899999999998")).longValue()) == 3445173361941522430L; // ugh
06555: (new Test("lov019")).ok = ((new com.ibm.icu.math.BigDecimal(
06556: "-888888888899999999998")).longValue()) == (-3445173361941522430L); // ugh
06557:
06558: // longValueExact --
06559:
06560: (new Test("lov101")).ok = lmin == ((new com.ibm.icu.math.BigDecimal(
06561: lmin)).longValue());
06562: (new Test("lov102")).ok = (((long) 99)) == ((new com.ibm.icu.math.BigDecimal(
06563: "99")).longValue());
06564: (new Test("lov103")).ok = (((long) 1)) == ((new com.ibm.icu.math.BigDecimal(
06565: "1")).longValue());
06566: (new Test("lov104")).ok = (((long) 0)) == ((new com.ibm.icu.math.BigDecimal(
06567: "0")).longValue());
06568: (new Test("lov105")).ok = (((long) -1)) == ((new com.ibm.icu.math.BigDecimal(
06569: "-1")).longValue());
06570: (new Test("lov106")).ok = (((long) -99)) == ((new com.ibm.icu.math.BigDecimal(
06571: "-99")).longValue());
06572: (new Test("lov107")).ok = lmax == ((new com.ibm.icu.math.BigDecimal(
06573: lmax)).longValue());
06574: (new Test("lov108")).ok = (((long) 5)) == ((new com.ibm.icu.math.BigDecimal(
06575: "5.0")).longValue());
06576: (new Test("lov109")).ok = (((long) -5)) == ((new com.ibm.icu.math.BigDecimal(
06577: "-5.0")).longValue());
06578:
06579: try {
06580: v = "-888888888899999999998";
06581: (new com.ibm.icu.math.BigDecimal(v)).longValueExact();
06582: flag = false;
06583: } catch (java.lang.ArithmeticException $110) {
06584: ae = $110;
06585: flag = (ae.getMessage()).equals("Conversion overflow:"
06586: + " " + v);
06587: }
06588: (new Test("lov200")).ok = flag;
06589: try {
06590: v = "88888887487487479488888";
06591: (new com.ibm.icu.math.BigDecimal(v)).longValueExact();
06592: flag = false;
06593: } catch (java.lang.ArithmeticException $111) {
06594: ae = $111;
06595: flag = (ae.getMessage()).equals("Conversion overflow:"
06596: + " " + v);
06597: }
06598: (new Test("lov201")).ok = flag;
06599: try {
06600: v = "1.5";
06601: (new com.ibm.icu.math.BigDecimal(v)).longValueExact();
06602: flag = false;
06603: } catch (java.lang.ArithmeticException $112) {
06604: ae = $112;
06605: flag = (ae.getMessage()).equals("Decimal part non-zero:"
06606: + " " + v);
06607: }
06608: (new Test("lov202")).ok = flag;
06609:
06610: badstrings = new java.lang.String[] {
06611: "1234567890110987654321",
06612: "-1234567890110987654321",
06613: (new com.ibm.icu.math.BigDecimal(lmax)).add(one)
06614: .toString(),
06615: (new com.ibm.icu.math.BigDecimal(lmin)).subtract(one)
06616: .toString(),
06617: (new com.ibm.icu.math.BigDecimal(lmin)).multiply(two)
06618: .toString(),
06619: (new com.ibm.icu.math.BigDecimal(lmax)).multiply(two)
06620: .toString(),
06621: (new com.ibm.icu.math.BigDecimal(lmin)).multiply(ten)
06622: .toString(),
06623: (new com.ibm.icu.math.BigDecimal(lmax)).multiply(ten)
06624: .toString(), "9223372036854775818",
06625: "9323372036854775818", "9423372036854775818",
06626: "9523372036854775818", "9623372036854775818",
06627: "9723372036854775818", "9823372036854775818",
06628: "9923372036854775818", "-9223372036854775818",
06629: "-9323372036854775818", "-9423372036854775818",
06630: "-9523372036854775818", "-9623372036854775818",
06631: "-9723372036854775818", "-9823372036854775818",
06632: "-9923372036854775818", "12345678901234567890" }; // 220
06633: // 221
06634: // 222
06635: // 223
06636: // 224
06637: // 225
06638: // 226
06639: // 227
06640: // 228
06641: // 229
06642: // 230
06643: // 231
06644: // 232
06645: // 233
06646: // 234
06647: // 235
06648: // 236
06649: // 237
06650: // 238
06651: // 239
06652: // 240
06653: // 241
06654: // 242
06655: // 243
06656: // 244
06657: {
06658: int $113 = badstrings.length;
06659: i = 0;
06660: i: for (; $113 > 0; $113--, i++) {
06661: try {
06662: v = badstrings[i];
06663: (new com.ibm.icu.math.BigDecimal(v))
06664: .longValueExact();
06665: flag = false;
06666: } catch (java.lang.ArithmeticException $114) {
06667: ae = $114;
06668: norm = (new com.ibm.icu.math.BigDecimal(v))
06669: .toString();
06670: flag = (ae.getMessage())
06671: .equals("Conversion overflow:" + " " + norm);
06672: }
06673: (new Test("lov" + (220 + i))).ok = flag;
06674: }
06675: }/*i*/
06676:
06677: // now slip in some single bits...
06678: dlmax = new com.ibm.icu.math.BigDecimal(lmax);
06679: {
06680: i = 0;
06681: i: for (; i <= 99; i++) {
06682: try {
06683: num = two.pow(new com.ibm.icu.math.BigDecimal(i),
06684: mc50);
06685: dv = dlmax.add(num, mc50);
06686: dv.longValueExact();
06687: flag = false;
06688: } catch (java.lang.ArithmeticException $115) {
06689: ae = $115;
06690: norm = dv.toString();
06691: flag = (ae.getMessage())
06692: .equals("Conversion overflow:" + " " + norm);
06693: }
06694: (new Test("lov" + (300 + i))).ok = flag;
06695: }
06696: }/*i*/
06697: dlmin = new com.ibm.icu.math.BigDecimal(lmin);
06698: {
06699: i = 0;
06700: i: for (; i <= 99; i++) {
06701: try {
06702: num = two.pow(new com.ibm.icu.math.BigDecimal(i),
06703: mc50);
06704: dv = dlmin.subtract(num, mc50);
06705: dv.longValueExact();
06706: flag = false;
06707: } catch (java.lang.ArithmeticException $116) {
06708: ae = $116;
06709: norm = dv.toString();
06710: flag = (ae.getMessage())
06711: .equals("Conversion overflow:" + " " + norm);
06712: }
06713: (new Test("lov" + (400 + i))).ok = flag;
06714: }
06715: }/*i*/
06716:
06717: summary("longValue+");
06718: }
06719:
06720: /* ----------------------------------------------------------------- */
06721:
06722: /** Test the {@link com.ibm.icu.math.BigDecimal#movePointLeft} method. */
06723:
06724: public void diagmovepointleft() {
06725: (new Test("mpl001")).ok = ((new com.ibm.icu.math.BigDecimal(
06726: "-1")).movePointLeft(-10).toString())
06727: .equals("-10000000000");
06728: (new Test("mpl002")).ok = ((new com.ibm.icu.math.BigDecimal(
06729: "-1")).movePointLeft(-5).toString()).equals("-100000");
06730: (new Test("mpl003")).ok = ((new com.ibm.icu.math.BigDecimal(
06731: "-1")).movePointLeft(-1).toString()).equals("-10");
06732: (new Test("mpl004")).ok = ((new com.ibm.icu.math.BigDecimal(
06733: "-1")).movePointLeft(0).toString()).equals("-1");
06734: (new Test("mpl005")).ok = ((new com.ibm.icu.math.BigDecimal(
06735: "-1")).movePointLeft(+1).toString()).equals("-0.1");
06736: (new Test("mpl006")).ok = ((new com.ibm.icu.math.BigDecimal(
06737: "-1")).movePointLeft(+5).toString()).equals("-0.00001");
06738: (new Test("mpl007")).ok = ((new com.ibm.icu.math.BigDecimal(
06739: "-1")).movePointLeft(+10).toString())
06740: .equals("-0.0000000001");
06741:
06742: (new Test("mpl010")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
06743: .movePointLeft(-10).toString()).equals("0");
06744: (new Test("mpl010")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
06745: .movePointLeft(-5).toString()).equals("0");
06746: (new Test("mpl010")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
06747: .movePointLeft(-1).toString()).equals("0");
06748: (new Test("mpl010")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
06749: .movePointLeft(0).toString()).equals("0");
06750: (new Test("mpl010")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
06751: .movePointLeft(+1).toString()).equals("0.0");
06752: (new Test("mpl010")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
06753: .movePointLeft(+5).toString()).equals("0.00000");
06754: (new Test("mpl010")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
06755: .movePointLeft(+10).toString()).equals("0.0000000000");
06756:
06757: (new Test("mpl020")).ok = ((new com.ibm.icu.math.BigDecimal(
06758: "+1")).movePointLeft(-10).toString())
06759: .equals("10000000000");
06760: (new Test("mpl021")).ok = ((new com.ibm.icu.math.BigDecimal(
06761: "+1")).movePointLeft(-5).toString()).equals("100000");
06762: (new Test("mpl022")).ok = ((new com.ibm.icu.math.BigDecimal(
06763: "+1")).movePointLeft(-1).toString()).equals("10");
06764: (new Test("mpl023")).ok = ((new com.ibm.icu.math.BigDecimal(
06765: "+1")).movePointLeft(0).toString()).equals("1");
06766: (new Test("mpl024")).ok = ((new com.ibm.icu.math.BigDecimal(
06767: "+1")).movePointLeft(+1).toString()).equals("0.1");
06768: (new Test("mpl025")).ok = ((new com.ibm.icu.math.BigDecimal(
06769: "+1")).movePointLeft(+5).toString()).equals("0.00001");
06770: (new Test("mpl026")).ok = ((new com.ibm.icu.math.BigDecimal(
06771: "+1")).movePointLeft(+10).toString())
06772: .equals("0.0000000001");
06773:
06774: (new Test("mpl030")).ok = ((new com.ibm.icu.math.BigDecimal(
06775: "0.5E+1")).movePointLeft(-10).toString())
06776: .equals("50000000000");
06777: (new Test("mpl031")).ok = ((new com.ibm.icu.math.BigDecimal(
06778: "0.5E+1")).movePointLeft(-5).toString())
06779: .equals("500000");
06780: (new Test("mpl032")).ok = ((new com.ibm.icu.math.BigDecimal(
06781: "0.5E+1")).movePointLeft(-1).toString()).equals("50");
06782: (new Test("mpl033")).ok = ((new com.ibm.icu.math.BigDecimal(
06783: "0.5E+1")).movePointLeft(0).toString()).equals("5");
06784: (new Test("mpl034")).ok = ((new com.ibm.icu.math.BigDecimal(
06785: "0.5E+1")).movePointLeft(+1).toString()).equals("0.5");
06786: (new Test("mpl035")).ok = ((new com.ibm.icu.math.BigDecimal(
06787: "0.5E+1")).movePointLeft(+5).toString())
06788: .equals("0.00005");
06789: (new Test("mpl036")).ok = ((new com.ibm.icu.math.BigDecimal(
06790: "0.5E+1")).movePointLeft(+10).toString())
06791: .equals("0.0000000005");
06792:
06793: summary("movePointLeft");
06794: }
06795:
06796: /* ----------------------------------------------------------------- */
06797:
06798: /** Test the {@link com.ibm.icu.math.BigDecimal#movePointRight} method. */
06799:
06800: public void diagmovepointright() {
06801: (new Test("mpr001")).ok = ((new com.ibm.icu.math.BigDecimal(
06802: "-1")).movePointRight(+10).toString())
06803: .equals("-10000000000");
06804: (new Test("mpr002")).ok = ((new com.ibm.icu.math.BigDecimal(
06805: "-1")).movePointRight(+5).toString()).equals("-100000");
06806: (new Test("mpr003")).ok = ((new com.ibm.icu.math.BigDecimal(
06807: "-1")).movePointRight(+1).toString()).equals("-10");
06808: (new Test("mpr004")).ok = ((new com.ibm.icu.math.BigDecimal(
06809: "-1")).movePointRight(0).toString()).equals("-1");
06810: (new Test("mpr005")).ok = ((new com.ibm.icu.math.BigDecimal(
06811: "-1")).movePointRight(-1).toString()).equals("-0.1");
06812: (new Test("mpr006")).ok = ((new com.ibm.icu.math.BigDecimal(
06813: "-1")).movePointRight(-5).toString())
06814: .equals("-0.00001");
06815: (new Test("mpr007")).ok = ((new com.ibm.icu.math.BigDecimal(
06816: "-1")).movePointRight(-10).toString())
06817: .equals("-0.0000000001");
06818:
06819: (new Test("mpr010")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
06820: .movePointRight(+10).toString()).equals("0");
06821: (new Test("mpr011")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
06822: .movePointRight(+5).toString()).equals("0");
06823: (new Test("mpr012")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
06824: .movePointRight(+1).toString()).equals("0");
06825: (new Test("mpr013")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
06826: .movePointRight(0).toString()).equals("0");
06827: (new Test("mpr014")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
06828: .movePointRight(-1).toString()).equals("0.0");
06829: (new Test("mpr015")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
06830: .movePointRight(-5).toString()).equals("0.00000");
06831: (new Test("mpr016")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
06832: .movePointRight(-10).toString()).equals("0.0000000000");
06833:
06834: (new Test("mpr020")).ok = ((new com.ibm.icu.math.BigDecimal(
06835: "+1")).movePointRight(+10).toString())
06836: .equals("10000000000");
06837: (new Test("mpr021")).ok = ((new com.ibm.icu.math.BigDecimal(
06838: "+1")).movePointRight(+5).toString()).equals("100000");
06839: (new Test("mpr022")).ok = ((new com.ibm.icu.math.BigDecimal(
06840: "+1")).movePointRight(+1).toString()).equals("10");
06841: (new Test("mpr023")).ok = ((new com.ibm.icu.math.BigDecimal(
06842: "+1")).movePointRight(0).toString()).equals("1");
06843: (new Test("mpr024")).ok = ((new com.ibm.icu.math.BigDecimal(
06844: "+1")).movePointRight(-1).toString()).equals("0.1");
06845: (new Test("mpr025")).ok = ((new com.ibm.icu.math.BigDecimal(
06846: "+1")).movePointRight(-5).toString()).equals("0.00001");
06847: (new Test("mpr026")).ok = ((new com.ibm.icu.math.BigDecimal(
06848: "+1")).movePointRight(-10).toString())
06849: .equals("0.0000000001");
06850:
06851: (new Test("mpr030")).ok = ((new com.ibm.icu.math.BigDecimal(
06852: "0.5E+1")).movePointRight(+10).toString())
06853: .equals("50000000000");
06854: (new Test("mpr031")).ok = ((new com.ibm.icu.math.BigDecimal(
06855: "0.5E+1")).movePointRight(+5).toString())
06856: .equals("500000");
06857: (new Test("mpr032")).ok = ((new com.ibm.icu.math.BigDecimal(
06858: "0.5E+1")).movePointRight(+1).toString()).equals("50");
06859: (new Test("mpr033")).ok = ((new com.ibm.icu.math.BigDecimal(
06860: "0.5E+1")).movePointRight(0).toString()).equals("5");
06861: (new Test("mpr034")).ok = ((new com.ibm.icu.math.BigDecimal(
06862: "0.5E+1")).movePointRight(-1).toString()).equals("0.5");
06863: (new Test("mpr035")).ok = ((new com.ibm.icu.math.BigDecimal(
06864: "0.5E+1")).movePointRight(-5).toString())
06865: .equals("0.00005");
06866: (new Test("mpr036")).ok = ((new com.ibm.icu.math.BigDecimal(
06867: "0.5E+1")).movePointRight(-10).toString())
06868: .equals("0.0000000005");
06869:
06870: summary("movePointRight");
06871: }
06872:
06873: /* ----------------------------------------------------------------- */
06874:
06875: /** Test the {@link com.ibm.icu.math.BigDecimal#scale} method. */
06876:
06877: public void diagscale() {
06878: (new Test("sca001")).ok = ((new com.ibm.icu.math.BigDecimal(
06879: "-1")).scale()) == 0;
06880: (new Test("sca002")).ok = ((new com.ibm.icu.math.BigDecimal(
06881: "-10")).scale()) == 0;
06882: (new Test("sca003")).ok = ((new com.ibm.icu.math.BigDecimal(
06883: "+1")).scale()) == 0;
06884: (new Test("sca004")).ok = ((new com.ibm.icu.math.BigDecimal(
06885: "+10")).scale()) == 0;
06886: (new Test("sca005")).ok = ((new com.ibm.icu.math.BigDecimal(
06887: "1E+10")).scale()) == 0;
06888: (new Test("sca006")).ok = ((new com.ibm.icu.math.BigDecimal(
06889: "1E-10")).scale()) == 10;
06890: (new Test("sca007")).ok = ((new com.ibm.icu.math.BigDecimal(
06891: "0E-10")).scale()) == 0;
06892: (new Test("sca008")).ok = ((new com.ibm.icu.math.BigDecimal(
06893: "0.000")).scale()) == 3;
06894: (new Test("sca009")).ok = ((new com.ibm.icu.math.BigDecimal(
06895: "0.00")).scale()) == 2;
06896: (new Test("sca010")).ok = ((new com.ibm.icu.math.BigDecimal(
06897: "0.0")).scale()) == 1;
06898: (new Test("sca011")).ok = ((new com.ibm.icu.math.BigDecimal(
06899: "0.1")).scale()) == 1;
06900: (new Test("sca012")).ok = ((new com.ibm.icu.math.BigDecimal(
06901: "0.12")).scale()) == 2;
06902: (new Test("sca013")).ok = ((new com.ibm.icu.math.BigDecimal(
06903: "0.123")).scale()) == 3;
06904: (new Test("sca014")).ok = ((new com.ibm.icu.math.BigDecimal(
06905: "-0.0")).scale()) == 1;
06906: (new Test("sca015")).ok = ((new com.ibm.icu.math.BigDecimal(
06907: "-0.1")).scale()) == 1;
06908: (new Test("sca016")).ok = ((new com.ibm.icu.math.BigDecimal(
06909: "-0.12")).scale()) == 2;
06910: (new Test("sca017")).ok = ((new com.ibm.icu.math.BigDecimal(
06911: "-0.123")).scale()) == 3;
06912: summary("scale");
06913: }
06914:
06915: /* ----------------------------------------------------------------- */
06916:
06917: /** Test the {@link com.ibm.icu.math.BigDecimal#setScale} method. */
06918:
06919: public void diagsetscale() {
06920: boolean flag = false;
06921: java.lang.RuntimeException e = null;
06922:
06923: (new Test("ssc001")).ok = ((new com.ibm.icu.math.BigDecimal(
06924: "-1")).setScale(0).toString()).equals("-1");
06925: (new Test("ssc002")).ok = ((new com.ibm.icu.math.BigDecimal(
06926: "-1")).setScale(1).toString()).equals("-1.0");
06927: (new Test("ssc003")).ok = ((new com.ibm.icu.math.BigDecimal(
06928: "-1")).setScale(2).toString()).equals("-1.00");
06929: (new Test("ssc004")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
06930: .setScale(0).toString()).equals("0");
06931: (new Test("ssc005")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
06932: .setScale(1).toString()).equals("0.0");
06933: (new Test("ssc006")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
06934: .setScale(2).toString()).equals("0.00");
06935: (new Test("ssc007")).ok = ((new com.ibm.icu.math.BigDecimal(
06936: "+1")).setScale(0).toString()).equals("1");
06937: (new Test("ssc008")).ok = ((new com.ibm.icu.math.BigDecimal(
06938: "+1")).setScale(1).toString()).equals("1.0");
06939: (new Test("ssc009")).ok = ((new com.ibm.icu.math.BigDecimal(
06940: "+1")).setScale(2).toString()).equals("1.00");
06941: (new Test("ssc010")).ok = ((new com.ibm.icu.math.BigDecimal(
06942: "-1")).setScale(0,
06943: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
06944: .equals("-1");
06945: (new Test("ssc011")).ok = ((new com.ibm.icu.math.BigDecimal(
06946: "-1")).setScale(1,
06947: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
06948: .equals("-1.0");
06949: (new Test("ssc012")).ok = ((new com.ibm.icu.math.BigDecimal(
06950: "-1")).setScale(2,
06951: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
06952: .equals("-1.00");
06953: (new Test("ssc013")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
06954: .setScale(0, com.ibm.icu.math.MathContext.ROUND_HALF_UP)
06955: .toString()).equals("0");
06956: (new Test("ssc014")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
06957: .setScale(1, com.ibm.icu.math.MathContext.ROUND_HALF_UP)
06958: .toString()).equals("0.0");
06959: (new Test("ssc015")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
06960: .setScale(2, com.ibm.icu.math.MathContext.ROUND_HALF_UP)
06961: .toString()).equals("0.00");
06962: (new Test("ssc016")).ok = ((new com.ibm.icu.math.BigDecimal(
06963: "+1")).setScale(0,
06964: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
06965: .equals("1");
06966: (new Test("ssc017")).ok = ((new com.ibm.icu.math.BigDecimal(
06967: "+1")).setScale(1,
06968: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
06969: .equals("1.0");
06970: (new Test("ssc018")).ok = ((new com.ibm.icu.math.BigDecimal(
06971: "+1")).setScale(2,
06972: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
06973: .equals("1.00");
06974:
06975: (new Test("ssc020")).ok = ((new com.ibm.icu.math.BigDecimal(
06976: "1.04")).setScale(3,
06977: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
06978: .equals("1.040");
06979: (new Test("ssc021")).ok = ((new com.ibm.icu.math.BigDecimal(
06980: "1.04")).setScale(2,
06981: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
06982: .equals("1.04");
06983: (new Test("ssc022")).ok = ((new com.ibm.icu.math.BigDecimal(
06984: "1.04")).setScale(1,
06985: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
06986: .equals("1.0");
06987: (new Test("ssc023")).ok = ((new com.ibm.icu.math.BigDecimal(
06988: "1.04")).setScale(0,
06989: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
06990: .equals("1");
06991: (new Test("ssc024")).ok = ((new com.ibm.icu.math.BigDecimal(
06992: "1.05")).setScale(3,
06993: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
06994: .equals("1.050");
06995: (new Test("ssc025")).ok = ((new com.ibm.icu.math.BigDecimal(
06996: "1.05")).setScale(2,
06997: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
06998: .equals("1.05");
06999: (new Test("ssc026")).ok = ((new com.ibm.icu.math.BigDecimal(
07000: "1.05")).setScale(1,
07001: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
07002: .equals("1.1");
07003: (new Test("ssc027")).ok = ((new com.ibm.icu.math.BigDecimal(
07004: "1.05")).setScale(0,
07005: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
07006: .equals("1");
07007: (new Test("ssc028")).ok = ((new com.ibm.icu.math.BigDecimal(
07008: "1.05")).setScale(3,
07009: com.ibm.icu.math.MathContext.ROUND_HALF_DOWN)
07010: .toString()).equals("1.050");
07011: (new Test("ssc029")).ok = ((new com.ibm.icu.math.BigDecimal(
07012: "1.05")).setScale(2,
07013: com.ibm.icu.math.MathContext.ROUND_HALF_DOWN)
07014: .toString()).equals("1.05");
07015: (new Test("ssc030")).ok = ((new com.ibm.icu.math.BigDecimal(
07016: "1.05")).setScale(1,
07017: com.ibm.icu.math.MathContext.ROUND_HALF_DOWN)
07018: .toString()).equals("1.0");
07019: (new Test("ssc031")).ok = ((new com.ibm.icu.math.BigDecimal(
07020: "1.05")).setScale(0,
07021: com.ibm.icu.math.MathContext.ROUND_HALF_DOWN)
07022: .toString()).equals("1");
07023: (new Test("ssc032")).ok = ((new com.ibm.icu.math.BigDecimal(
07024: "1.06")).setScale(3,
07025: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
07026: .equals("1.060");
07027: (new Test("ssc033")).ok = ((new com.ibm.icu.math.BigDecimal(
07028: "1.06")).setScale(2,
07029: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
07030: .equals("1.06");
07031: (new Test("ssc034")).ok = ((new com.ibm.icu.math.BigDecimal(
07032: "1.06")).setScale(1,
07033: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
07034: .equals("1.1");
07035: (new Test("ssc035")).ok = ((new com.ibm.icu.math.BigDecimal(
07036: "1.06")).setScale(0,
07037: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
07038: .equals("1");
07039:
07040: (new Test("ssc040")).ok = ((new com.ibm.icu.math.BigDecimal(
07041: "-10")).setScale(2,
07042: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
07043: .equals("-10.00");
07044: (new Test("ssc041")).ok = ((new com.ibm.icu.math.BigDecimal(
07045: "+1")).setScale(2,
07046: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
07047: .equals("1.00");
07048: (new Test("ssc042")).ok = ((new com.ibm.icu.math.BigDecimal(
07049: "+10")).setScale(2,
07050: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
07051: .equals("10.00");
07052: (new Test("ssc043")).ok = ((new com.ibm.icu.math.BigDecimal(
07053: "1E+10")).setScale(2,
07054: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
07055: .equals("10000000000.00");
07056: (new Test("ssc044")).ok = ((new com.ibm.icu.math.BigDecimal(
07057: "1E-10")).setScale(2,
07058: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
07059: .equals("0.00");
07060: (new Test("ssc045")).ok = ((new com.ibm.icu.math.BigDecimal(
07061: "1E-2")).setScale(2,
07062: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
07063: .equals("0.01");
07064: (new Test("ssc046")).ok = ((new com.ibm.icu.math.BigDecimal(
07065: "0E-10")).setScale(2,
07066: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
07067: .equals("0.00");
07068:
07069: // check rounding
07070: (new Test("ssc050")).ok = ((new com.ibm.icu.math.BigDecimal(
07071: "0.005")).setScale(2,
07072: com.ibm.icu.math.MathContext.ROUND_CEILING).toString())
07073: .equals("0.01");
07074: (new Test("ssc051")).ok = ((new com.ibm.icu.math.BigDecimal(
07075: "0.005")).setScale(1,
07076: com.ibm.icu.math.MathContext.ROUND_CEILING).toString())
07077: .equals("0.1");
07078: (new Test("ssc052")).ok = ((new com.ibm.icu.math.BigDecimal(
07079: "0.005")).setScale(0,
07080: com.ibm.icu.math.MathContext.ROUND_CEILING).toString())
07081: .equals("1");
07082: (new Test("ssc053")).ok = ((new com.ibm.icu.math.BigDecimal(
07083: "0.005")).setScale(2,
07084: com.ibm.icu.math.MathContext.ROUND_DOWN).toString())
07085: .equals("0.00");
07086: (new Test("ssc054")).ok = ((new com.ibm.icu.math.BigDecimal(
07087: "0.005")).setScale(1,
07088: com.ibm.icu.math.MathContext.ROUND_DOWN).toString())
07089: .equals("0.0");
07090: (new Test("ssc055")).ok = ((new com.ibm.icu.math.BigDecimal(
07091: "0.005")).setScale(0,
07092: com.ibm.icu.math.MathContext.ROUND_DOWN).toString())
07093: .equals("0");
07094: (new Test("ssc056")).ok = ((new com.ibm.icu.math.BigDecimal(
07095: "0.005")).setScale(2,
07096: com.ibm.icu.math.MathContext.ROUND_FLOOR).toString())
07097: .equals("0.00");
07098: (new Test("ssc057")).ok = ((new com.ibm.icu.math.BigDecimal(
07099: "0.005")).setScale(1,
07100: com.ibm.icu.math.MathContext.ROUND_FLOOR).toString())
07101: .equals("0.0");
07102: (new Test("ssc058")).ok = ((new com.ibm.icu.math.BigDecimal(
07103: "0.005")).setScale(0,
07104: com.ibm.icu.math.MathContext.ROUND_FLOOR).toString())
07105: .equals("0");
07106: (new Test("ssc059")).ok = ((new com.ibm.icu.math.BigDecimal(
07107: "0.005")).setScale(2,
07108: com.ibm.icu.math.MathContext.ROUND_HALF_DOWN)
07109: .toString()).equals("0.00");
07110: (new Test("ssc060")).ok = ((new com.ibm.icu.math.BigDecimal(
07111: "0.005")).setScale(1,
07112: com.ibm.icu.math.MathContext.ROUND_HALF_DOWN)
07113: .toString()).equals("0.0");
07114: (new Test("ssc061")).ok = ((new com.ibm.icu.math.BigDecimal(
07115: "0.005")).setScale(0,
07116: com.ibm.icu.math.MathContext.ROUND_HALF_DOWN)
07117: .toString()).equals("0");
07118: (new Test("ssc062")).ok = ((new com.ibm.icu.math.BigDecimal(
07119: "0.005")).setScale(2,
07120: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN)
07121: .toString()).equals("0.00");
07122: (new Test("ssc063")).ok = ((new com.ibm.icu.math.BigDecimal(
07123: "0.005")).setScale(1,
07124: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN)
07125: .toString()).equals("0.0");
07126: (new Test("ssc064")).ok = ((new com.ibm.icu.math.BigDecimal(
07127: "0.005")).setScale(0,
07128: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN)
07129: .toString()).equals("0");
07130: (new Test("ssc065")).ok = ((new com.ibm.icu.math.BigDecimal(
07131: "0.015")).setScale(2,
07132: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN)
07133: .toString()).equals("0.02");
07134: (new Test("ssc066")).ok = ((new com.ibm.icu.math.BigDecimal(
07135: "0.015")).setScale(1,
07136: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN)
07137: .toString()).equals("0.0");
07138: (new Test("ssc067")).ok = ((new com.ibm.icu.math.BigDecimal(
07139: "0.015")).setScale(0,
07140: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN)
07141: .toString()).equals("0");
07142: (new Test("ssc068")).ok = ((new com.ibm.icu.math.BigDecimal(
07143: "0.005")).setScale(2,
07144: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
07145: .equals("0.01");
07146: (new Test("ssc069")).ok = ((new com.ibm.icu.math.BigDecimal(
07147: "0.005")).setScale(1,
07148: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
07149: .equals("0.0");
07150: (new Test("ssc070")).ok = ((new com.ibm.icu.math.BigDecimal(
07151: "0.005")).setScale(0,
07152: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
07153: .equals("0");
07154: (new Test("ssc071")).ok = ((new com.ibm.icu.math.BigDecimal(
07155: "0.095")).setScale(2,
07156: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
07157: .equals("0.10");
07158: (new Test("ssc072")).ok = ((new com.ibm.icu.math.BigDecimal(
07159: "0.095")).setScale(1,
07160: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
07161: .equals("0.1");
07162: (new Test("ssc073")).ok = ((new com.ibm.icu.math.BigDecimal(
07163: "0.095")).setScale(0,
07164: com.ibm.icu.math.MathContext.ROUND_HALF_UP).toString())
07165: .equals("0");
07166: (new Test("ssc074")).ok = ((new com.ibm.icu.math.BigDecimal(
07167: "0.005")).setScale(2,
07168: com.ibm.icu.math.MathContext.ROUND_UP).toString())
07169: .equals("0.01");
07170: (new Test("ssc075")).ok = ((new com.ibm.icu.math.BigDecimal(
07171: "0.005")).setScale(1,
07172: com.ibm.icu.math.MathContext.ROUND_UP).toString())
07173: .equals("0.1");
07174: (new Test("ssc076")).ok = ((new com.ibm.icu.math.BigDecimal(
07175: "0.005")).setScale(0,
07176: com.ibm.icu.math.MathContext.ROUND_UP).toString())
07177: .equals("1");
07178:
07179: try {
07180: checkscale: do {
07181: (new com.ibm.icu.math.BigDecimal(1)).setScale(-8);
07182: flag = false;
07183: } while (false);
07184: } catch (java.lang.RuntimeException $117) {
07185: e = $117;
07186: flag = (e.getMessage()).equals("Negative scale: -8");
07187: }/*checkscale*/
07188: (new Test("ssc100")).ok = flag;
07189: try {
07190: checkrunn: do {
07191: (new com.ibm.icu.math.BigDecimal(1.0001D)).setScale(3);
07192: flag = false;
07193: } while (false);
07194: } catch (java.lang.RuntimeException $118) {
07195: e = $118;
07196: flag = (e.getMessage()).equals("Rounding necessary");
07197: }/*checkrunn*/
07198: (new Test("ssc101")).ok = flag;
07199: try {
07200: checkrunn: do {
07201: (new com.ibm.icu.math.BigDecimal(1E-8D)).setScale(3);
07202: flag = false;
07203: } while (false);
07204: } catch (java.lang.RuntimeException $119) {
07205: e = $119;
07206: flag = (e.getMessage()).equals("Rounding necessary");
07207: }/*checkrunn*/
07208: (new Test("ssc102")).ok = flag;
07209: summary("setScale");
07210: }
07211:
07212: /* ----------------------------------------------------------------- */
07213:
07214: /** Test the <code>BigDecimal.shortValue()</code> method. */
07215:
07216: public void diagshortvalue() {
07217: boolean flag = false;
07218: java.lang.String v = null;
07219: java.lang.ArithmeticException ae = null;
07220: java.lang.String badstrings[];
07221: int i = 0;
07222: java.lang.String norm = null;
07223:
07224: (new Test("shv002")).ok = (((short) 0)) == ((new com.ibm.icu.math.BigDecimal(
07225: "0")).shortValue());
07226: (new Test("shv003")).ok = (((short) 1)) == ((new com.ibm.icu.math.BigDecimal(
07227: "1")).shortValue());
07228: (new Test("shv004")).ok = (((short) 99)) == ((new com.ibm.icu.math.BigDecimal(
07229: "99")).shortValue());
07230: (new Test("shv006")).ok = ((smax)) == ((new com.ibm.icu.math.BigDecimal(
07231: smax)).shortValue());
07232: (new Test("shv007")).ok = ((smin)) == ((new com.ibm.icu.math.BigDecimal(
07233: smin)).shortValue());
07234: (new Test("shv008")).ok = ((sneg)) == ((new com.ibm.icu.math.BigDecimal(
07235: sneg)).shortValue());
07236: (new Test("shv009")).ok = ((szer)) == ((new com.ibm.icu.math.BigDecimal(
07237: szer)).shortValue());
07238: (new Test("shv010")).ok = ((spos)) == ((new com.ibm.icu.math.BigDecimal(
07239: spos)).shortValue());
07240: (new Test("shv011")).ok = ((smin)) == ((new com.ibm.icu.math.BigDecimal(
07241: smax + 1)).shortValue());
07242: (new Test("shv012")).ok = ((smax)) == ((new com.ibm.icu.math.BigDecimal(
07243: smin - 1)).shortValue());
07244:
07245: (new Test("shv022")).ok = (((short) 0)) == ((new com.ibm.icu.math.BigDecimal(
07246: "0")).shortValueExact());
07247: (new Test("shv023")).ok = (((short) 1)) == ((new com.ibm.icu.math.BigDecimal(
07248: "1")).shortValueExact());
07249: (new Test("shv024")).ok = (((short) 99)) == ((new com.ibm.icu.math.BigDecimal(
07250: "99")).shortValueExact());
07251: (new Test("shv026")).ok = ((smax)) == ((new com.ibm.icu.math.BigDecimal(
07252: smax)).shortValueExact());
07253: (new Test("shv027")).ok = ((smin)) == ((new com.ibm.icu.math.BigDecimal(
07254: smin)).shortValueExact());
07255: (new Test("shv028")).ok = ((sneg)) == ((new com.ibm.icu.math.BigDecimal(
07256: sneg)).shortValueExact());
07257: (new Test("shv029")).ok = ((szer)) == ((new com.ibm.icu.math.BigDecimal(
07258: szer)).shortValueExact());
07259: (new Test("shv030")).ok = ((spos)) == ((new com.ibm.icu.math.BigDecimal(
07260: spos)).shortValueExact());
07261: try {
07262: v = "-88888888888";
07263: (new com.ibm.icu.math.BigDecimal(v)).shortValueExact();
07264: flag = false;
07265: } catch (java.lang.ArithmeticException $120) {
07266: ae = $120;
07267: flag = (ae.getMessage()).equals("Conversion overflow:"
07268: + " " + v);
07269: }
07270: (new Test("shv100")).ok = flag;
07271: try {
07272: v = "88888888888";
07273: (new com.ibm.icu.math.BigDecimal(v)).shortValueExact();
07274: flag = false;
07275: } catch (java.lang.ArithmeticException $121) {
07276: ae = $121;
07277: flag = (ae.getMessage()).equals("Conversion overflow:"
07278: + " " + v);
07279: }
07280: (new Test("shv101")).ok = flag;
07281: try {
07282: v = "1.5";
07283: (new com.ibm.icu.math.BigDecimal(v)).shortValueExact();
07284: flag = false;
07285: } catch (java.lang.ArithmeticException $122) {
07286: ae = $122;
07287: flag = (ae.getMessage()).equals("Decimal part non-zero:"
07288: + " " + v);
07289: }
07290: (new Test("shv102")).ok = flag;
07291:
07292: badstrings = new java.lang.String[] {
07293: "123456",
07294: (new com.ibm.icu.math.BigDecimal(smax)).add(one)
07295: .toString(),
07296: (new com.ibm.icu.math.BigDecimal(smin)).subtract(one)
07297: .toString(),
07298: "71111",
07299: "81111",
07300: "91111",
07301: "-71111",
07302: "-81111",
07303: "-91111",
07304: (new com.ibm.icu.math.BigDecimal(smin)).multiply(two)
07305: .toString(),
07306: (new com.ibm.icu.math.BigDecimal(smax)).multiply(two)
07307: .toString(),
07308: (new com.ibm.icu.math.BigDecimal(smin)).multiply(ten)
07309: .toString(),
07310: (new com.ibm.icu.math.BigDecimal(smax)).multiply(ten)
07311: .toString(), "-123456" }; // 220
07312: // 221
07313: // 222
07314: // 223
07315: // 224
07316: // 225
07317: // 226
07318: // 227
07319: // 228
07320: // 229
07321: // 230
07322: // 231
07323: // 232
07324: // 233
07325: {
07326: int $123 = badstrings.length;
07327: i = 0;
07328: i: for (; $123 > 0; $123--, i++) {
07329: try {
07330: v = badstrings[i];
07331: (new com.ibm.icu.math.BigDecimal(v))
07332: .shortValueExact();
07333: flag = false;
07334: } catch (java.lang.ArithmeticException $124) {
07335: ae = $124;
07336: norm = (new com.ibm.icu.math.BigDecimal(v))
07337: .toString();
07338: flag = (ae.getMessage())
07339: .equals("Conversion overflow:" + " " + norm);
07340: }
07341: (new Test("shv" + (220 + i))).ok = flag;
07342: }
07343: }/*i*/
07344:
07345: summary("shortValue+");
07346: }
07347:
07348: /* ----------------------------------------------------------------- */
07349:
07350: /** Test the {@link com.ibm.icu.math.BigDecimal#signum} method. */
07351:
07352: public void diagsignum() {
07353: // necessarily checks some obscure constructions, too
07354: (new Test("sig001")).ok = (-1) == ((new com.ibm.icu.math.BigDecimal(
07355: "-1")).signum());
07356: (new Test("sig002")).ok = (-1) == ((new com.ibm.icu.math.BigDecimal(
07357: "-0.0010")).signum());
07358: (new Test("sig003")).ok = (-1) == ((new com.ibm.icu.math.BigDecimal(
07359: "-0.001")).signum());
07360: (new Test("sig004")).ok = 0 == ((new com.ibm.icu.math.BigDecimal(
07361: "-0.00")).signum());
07362: (new Test("sig005")).ok = 0 == ((new com.ibm.icu.math.BigDecimal(
07363: "-0")).signum());
07364: (new Test("sig006")).ok = 0 == ((new com.ibm.icu.math.BigDecimal(
07365: "0")).signum());
07366: (new Test("sig007")).ok = 0 == ((new com.ibm.icu.math.BigDecimal(
07367: "00")).signum());
07368: (new Test("sig008")).ok = 0 == ((new com.ibm.icu.math.BigDecimal(
07369: "00.0")).signum());
07370: (new Test("sig009")).ok = 1 == ((new com.ibm.icu.math.BigDecimal(
07371: "00.01")).signum());
07372: (new Test("sig010")).ok = 1 == ((new com.ibm.icu.math.BigDecimal(
07373: "00.01")).signum());
07374: (new Test("sig011")).ok = 1 == ((new com.ibm.icu.math.BigDecimal(
07375: "00.010")).signum());
07376: (new Test("sig012")).ok = 1 == ((new com.ibm.icu.math.BigDecimal(
07377: "01.01")).signum());
07378: (new Test("sig013")).ok = 1 == ((new com.ibm.icu.math.BigDecimal(
07379: "+0.01")).signum());
07380: (new Test("sig014")).ok = 1 == ((new com.ibm.icu.math.BigDecimal(
07381: "+0.001")).signum());
07382: (new Test("sig015")).ok = 1 == ((new com.ibm.icu.math.BigDecimal(
07383: "1")).signum());
07384: (new Test("sig016")).ok = 1 == ((new com.ibm.icu.math.BigDecimal(
07385: "1e+12")).signum());
07386: (new Test("sig017")).ok = 0 == ((new com.ibm.icu.math.BigDecimal(
07387: "00e+12")).signum());
07388: summary("signum");
07389: }
07390:
07391: /* ----------------------------------------------------------------- */
07392:
07393: /** Test the {@link com.ibm.icu.math.BigDecimal#toBigDecimal} method. */
07394:
07395: public void diagtobigdecimal() {
07396: //#ifndef FOUNDATION
07397: (new Test("tbd001")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
07398: .toBigDecimal().toString()).equals("0");
07399: (new Test("tbd002")).ok = ((new com.ibm.icu.math.BigDecimal(
07400: "-1")).toBigDecimal().toString()).equals("-1");
07401: (new Test("tbd003")).ok = ((new com.ibm.icu.math.BigDecimal(
07402: "+1")).toBigDecimal().toString()).equals("1");
07403: (new Test("tbd004")).ok = ((new com.ibm.icu.math.BigDecimal("1"))
07404: .toBigDecimal().toString()).equals("1");
07405: (new Test("tbd005")).ok = ((new com.ibm.icu.math.BigDecimal(
07406: "1E+2")).toBigDecimal().toString()).equals("100");
07407: (new Test("tbd006")).ok = ((new com.ibm.icu.math.BigDecimal(
07408: "1E-2")).toBigDecimal().toString()).equals("0.01");
07409: if (!isJDK15OrLater)
07410: (new Test("tbd007")).ok = ((new com.ibm.icu.math.BigDecimal(
07411: "1E-8")).toBigDecimal().toString())
07412: .equals("0.00000001");
07413: if (!isJDK15OrLater)
07414: (new Test("tbd008")).ok = ((new com.ibm.icu.math.BigDecimal(
07415: "1E-9")).toBigDecimal().toString())
07416: .equals("0.000000001");
07417: (new Test("tbd009")).ok = ((new com.ibm.icu.math.BigDecimal(
07418: "1E10")).toBigDecimal().toString())
07419: .equals("10000000000");
07420: (new Test("tbd010")).ok = ((new com.ibm.icu.math.BigDecimal(
07421: "1E12")).toBigDecimal().toString())
07422: .equals("1000000000000");
07423: summary("toBigDecimal");
07424: //#endif
07425: }
07426:
07427: /* ----------------------------------------------------------------- */
07428:
07429: /** Test the {@link com.ibm.icu.math.BigDecimal#toBigInteger} method. */
07430:
07431: public void diagtobiginteger() {
07432: boolean flag = false;
07433: java.lang.String badstrings[];
07434: int i = 0;
07435: (new Test("tbi001")).ok = ((new com.ibm.icu.math.BigDecimal(
07436: "-1")).toBigInteger().toString()).equals("-1");
07437: (new Test("tbi002")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
07438: .toBigInteger().toString()).equals("0");
07439: (new Test("tbi003")).ok = ((new com.ibm.icu.math.BigDecimal(
07440: "+1")).toBigInteger().toString()).equals("1");
07441: (new Test("tbi004")).ok = ((new com.ibm.icu.math.BigDecimal(
07442: "10")).toBigInteger().toString()).equals("10");
07443: (new Test("tbi005")).ok = ((new com.ibm.icu.math.BigDecimal(
07444: "1000")).toBigInteger().toString()).equals("1000");
07445: (new Test("tbi006")).ok = ((new com.ibm.icu.math.BigDecimal(
07446: "-1E+0")).toBigInteger().toString()).equals("-1");
07447: (new Test("tbi007")).ok = ((new com.ibm.icu.math.BigDecimal(
07448: "0E+0")).toBigInteger().toString()).equals("0");
07449: (new Test("tbi008")).ok = ((new com.ibm.icu.math.BigDecimal(
07450: "+1E+0")).toBigInteger().toString()).equals("1");
07451: (new Test("tbi009")).ok = ((new com.ibm.icu.math.BigDecimal(
07452: "10E+0")).toBigInteger().toString()).equals("10");
07453: (new Test("tbi010")).ok = ((new com.ibm.icu.math.BigDecimal(
07454: "1E+3")).toBigInteger().toString()).equals("1000");
07455: (new Test("tbi011")).ok = ((new com.ibm.icu.math.BigDecimal(
07456: "0.00")).toBigInteger().toString()).equals("0");
07457: (new Test("tbi012")).ok = ((new com.ibm.icu.math.BigDecimal(
07458: "0.01")).toBigInteger().toString()).equals("0");
07459: (new Test("tbi013")).ok = ((new com.ibm.icu.math.BigDecimal(
07460: "0.0")).toBigInteger().toString()).equals("0");
07461: (new Test("tbi014")).ok = ((new com.ibm.icu.math.BigDecimal(
07462: "0.1")).toBigInteger().toString()).equals("0");
07463: (new Test("tbi015")).ok = ((new com.ibm.icu.math.BigDecimal(
07464: "-0.00")).toBigInteger().toString()).equals("0");
07465: (new Test("tbi016")).ok = ((new com.ibm.icu.math.BigDecimal(
07466: "-0.01")).toBigInteger().toString()).equals("0");
07467: (new Test("tbi017")).ok = ((new com.ibm.icu.math.BigDecimal(
07468: "-0.0")).toBigInteger().toString()).equals("0");
07469: (new Test("tbi018")).ok = ((new com.ibm.icu.math.BigDecimal(
07470: "-0.1")).toBigInteger().toString()).equals("0");
07471: (new Test("tbi019")).ok = ((new com.ibm.icu.math.BigDecimal(
07472: "1.00")).toBigInteger().toString()).equals("1");
07473: (new Test("tbi020")).ok = ((new com.ibm.icu.math.BigDecimal(
07474: "1.01")).toBigInteger().toString()).equals("1");
07475: (new Test("tbi021")).ok = ((new com.ibm.icu.math.BigDecimal(
07476: "1.0")).toBigInteger().toString()).equals("1");
07477: (new Test("tbi022")).ok = ((new com.ibm.icu.math.BigDecimal(
07478: "1.1")).toBigInteger().toString()).equals("1");
07479: (new Test("tbi023")).ok = ((new com.ibm.icu.math.BigDecimal(
07480: "-1.00")).toBigInteger().toString()).equals("-1");
07481: (new Test("tbi024")).ok = ((new com.ibm.icu.math.BigDecimal(
07482: "-1.01")).toBigInteger().toString()).equals("-1");
07483: (new Test("tbi025")).ok = ((new com.ibm.icu.math.BigDecimal(
07484: "-1.0")).toBigInteger().toString()).equals("-1");
07485: (new Test("tbi026")).ok = ((new com.ibm.icu.math.BigDecimal(
07486: "-1.1")).toBigInteger().toString()).equals("-1");
07487: (new Test("tbi027")).ok = ((new com.ibm.icu.math.BigDecimal(
07488: "-111.111")).toBigInteger().toString()).equals("-111");
07489: (new Test("tbi028")).ok = ((new com.ibm.icu.math.BigDecimal(
07490: "+111.111")).toBigInteger().toString()).equals("111");
07491: (new Test("tbi029")).ok = ((new com.ibm.icu.math.BigDecimal(
07492: "0.09")).toBigInteger().toString()).equals("0");
07493: (new Test("tbi030")).ok = ((new com.ibm.icu.math.BigDecimal(
07494: "0.9")).toBigInteger().toString()).equals("0");
07495: (new Test("tbi031")).ok = ((new com.ibm.icu.math.BigDecimal(
07496: "1.09")).toBigInteger().toString()).equals("1");
07497: (new Test("tbi032")).ok = ((new com.ibm.icu.math.BigDecimal(
07498: "1.05")).toBigInteger().toString()).equals("1");
07499: (new Test("tbi033")).ok = ((new com.ibm.icu.math.BigDecimal(
07500: "1.04")).toBigInteger().toString()).equals("1");
07501: (new Test("tbi034")).ok = ((new com.ibm.icu.math.BigDecimal(
07502: "1.99")).toBigInteger().toString()).equals("1");
07503: (new Test("tbi034")).ok = ((new com.ibm.icu.math.BigDecimal(
07504: "1.9")).toBigInteger().toString()).equals("1");
07505: (new Test("tbi035")).ok = ((new com.ibm.icu.math.BigDecimal(
07506: "1.5")).toBigInteger().toString()).equals("1");
07507: (new Test("tbi036")).ok = ((new com.ibm.icu.math.BigDecimal(
07508: "1.4")).toBigInteger().toString()).equals("1");
07509: (new Test("tbi037")).ok = ((new com.ibm.icu.math.BigDecimal(
07510: "-1.09")).toBigInteger().toString()).equals("-1");
07511: (new Test("tbi038")).ok = ((new com.ibm.icu.math.BigDecimal(
07512: "-1.05")).toBigInteger().toString()).equals("-1");
07513: (new Test("tbi039")).ok = ((new com.ibm.icu.math.BigDecimal(
07514: "-1.04")).toBigInteger().toString()).equals("-1");
07515: (new Test("tbi040")).ok = ((new com.ibm.icu.math.BigDecimal(
07516: "-1.99")).toBigInteger().toString()).equals("-1");
07517: (new Test("tbi041")).ok = ((new com.ibm.icu.math.BigDecimal(
07518: "-1.9")).toBigInteger().toString()).equals("-1");
07519: (new Test("tbi042")).ok = ((new com.ibm.icu.math.BigDecimal(
07520: "-1.5")).toBigInteger().toString()).equals("-1");
07521: (new Test("tbi043")).ok = ((new com.ibm.icu.math.BigDecimal(
07522: "-1.4")).toBigInteger().toString()).equals("-1");
07523: (new Test("tbi044")).ok = ((new com.ibm.icu.math.BigDecimal(
07524: "1E-1000")).toBigInteger().toString()).equals("0");
07525: (new Test("tbi045")).ok = ((new com.ibm.icu.math.BigDecimal(
07526: "-1E-1000")).toBigInteger().toString()).equals("0");
07527:
07528: // Exact variety --
07529: (new Test("tbi101")).ok = ((new com.ibm.icu.math.BigDecimal(
07530: "-1")).toBigIntegerExact().toString()).equals("-1");
07531: (new Test("tbi102")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
07532: .toBigIntegerExact().toString()).equals("0");
07533: (new Test("tbi103")).ok = ((new com.ibm.icu.math.BigDecimal(
07534: "+1")).toBigIntegerExact().toString()).equals("1");
07535: (new Test("tbi104")).ok = ((new com.ibm.icu.math.BigDecimal(
07536: "10")).toBigIntegerExact().toString()).equals("10");
07537: (new Test("tbi105")).ok = ((new com.ibm.icu.math.BigDecimal(
07538: "1000")).toBigIntegerExact().toString()).equals("1000");
07539: (new Test("tbi106")).ok = ((new com.ibm.icu.math.BigDecimal(
07540: "-1E+0")).toBigIntegerExact().toString()).equals("-1");
07541: (new Test("tbi107")).ok = ((new com.ibm.icu.math.BigDecimal(
07542: "0E+0")).toBigIntegerExact().toString()).equals("0");
07543: (new Test("tbi108")).ok = ((new com.ibm.icu.math.BigDecimal(
07544: "+1E+0")).toBigIntegerExact().toString()).equals("1");
07545: (new Test("tbi109")).ok = ((new com.ibm.icu.math.BigDecimal(
07546: "10E+0")).toBigIntegerExact().toString()).equals("10");
07547: (new Test("tbi110")).ok = ((new com.ibm.icu.math.BigDecimal(
07548: "1E+3")).toBigIntegerExact().toString()).equals("1000");
07549: (new Test("tbi111")).ok = ((new com.ibm.icu.math.BigDecimal(
07550: "0.00")).toBigIntegerExact().toString()).equals("0");
07551: (new Test("tbi112")).ok = ((new com.ibm.icu.math.BigDecimal(
07552: "0.0")).toBigIntegerExact().toString()).equals("0");
07553: (new Test("tbi113")).ok = ((new com.ibm.icu.math.BigDecimal(
07554: "-0.00")).toBigIntegerExact().toString()).equals("0");
07555: (new Test("tbi114")).ok = ((new com.ibm.icu.math.BigDecimal(
07556: "-0.0")).toBigIntegerExact().toString()).equals("0");
07557: (new Test("tbi115")).ok = ((new com.ibm.icu.math.BigDecimal(
07558: "1.00")).toBigIntegerExact().toString()).equals("1");
07559: (new Test("tbi116")).ok = ((new com.ibm.icu.math.BigDecimal(
07560: "1.0")).toBigIntegerExact().toString()).equals("1");
07561: (new Test("tbi117")).ok = ((new com.ibm.icu.math.BigDecimal(
07562: "-1.00")).toBigIntegerExact().toString()).equals("-1");
07563: (new Test("tbi118")).ok = ((new com.ibm.icu.math.BigDecimal(
07564: "-1.0")).toBigIntegerExact().toString()).equals("-1");
07565: (new Test("tbi119")).ok = ((new com.ibm.icu.math.BigDecimal(
07566: "1.00000000000000000000000000000")).toBigIntegerExact()
07567: .toString()).equals("1");
07568:
07569: // the following should all raise exceptions
07570:
07571: badstrings = new java.lang.String[] { "0.09", "0.9", "0.01",
07572: "0.1", "-0.01", "-0.1", "1.01", "-1.01", "-1.1",
07573: "-111.111", "+111.111", "1.09", "1.05", "1.04", "1.99",
07574: "1.9", "1.5", "1.4", "-1.09", "-1.05", "-1.04",
07575: "-1.99", "-1.9", "-1.5", "-1.4", "1E-1000", "-1E-1000",
07576: "11E-1", "1.1",
07577: "127623156123656561356123512315631231551312356.000001",
07578: "0.000000000000000000000000000000000000000000000001" }; // 300-303
07579: // 304-307
07580: // 308-311
07581: // 312-316
07582: // 317-320
07583: // 321-324
07584: // 325-328
07585: // 329
07586: // 330
07587:
07588: {
07589: int $125 = badstrings.length;
07590: i = 0;
07591: i: for (; $125 > 0; $125--, i++) {
07592: try {
07593: (new com.ibm.icu.math.BigDecimal(badstrings[i]))
07594: .toBigIntegerExact();
07595: flag = false;
07596: } catch (java.lang.ArithmeticException $126) {
07597: flag = true;
07598: }
07599: (new Test("tbi" + (300 + i))).ok = flag;
07600: }
07601: }/*i*/
07602:
07603: summary("toBigInteger+");
07604: }
07605:
07606: /* ----------------------------------------------------------------- */
07607:
07608: /** Test the {@link com.ibm.icu.math.BigDecimal#toCharArray} method. */
07609:
07610: public void diagtochararray() {
07611: java.lang.String str;
07612: char car[];
07613: com.ibm.icu.math.BigDecimal d;
07614: char ca[];
07615: // the function of this has been tested above, this is simply an
07616: // existence proof and type-check
07617: str = "-123.45";
07618: car = (str).toCharArray();
07619: d = new com.ibm.icu.math.BigDecimal(str);
07620: ca = d.toCharArray();
07621: (new Test("tca001")).ok = ca.length == car.length;
07622: (new Test("tca002")).ok = (new java.lang.String(ca))
07623: .equals((java.lang.Object) (new java.lang.String(car)));
07624: (new Test("tca003")).ok = (d.toCharArray() instanceof char[]);
07625: (new Test("tca004")).ok = (ca instanceof char[]);
07626: summary("toCharArray");
07627: }
07628:
07629: /* ----------------------------------------------------------------- */
07630:
07631: /** Test the {@link com.ibm.icu.math.BigDecimal#toString} method. */
07632:
07633: public void diagtostring() {
07634: java.lang.String str;
07635: char car[];
07636: com.ibm.icu.math.BigDecimal d;
07637: char ca[];
07638: java.lang.String cs;
07639: // the function of this has been tested above, this is simply an
07640: // existence proof and type-check
07641: str = "123.45";
07642: car = (str).toCharArray();
07643: d = new com.ibm.icu.math.BigDecimal(car, 0, car.length);
07644: ca = d.toCharArray();
07645: cs = d.toString();
07646: (new Test("tos001")).ok = (str.toCharArray().length) == ca.length;
07647: (new Test("tos002")).ok = (str.length()) == (cs.length());
07648: (new Test("tos003")).ok = str
07649: .equals((java.lang.Object) (new java.lang.String(ca)));
07650: (new Test("tos004")).ok = str.equals((java.lang.Object) cs);
07651: (new Test("tos005")).ok = (cs instanceof java.lang.String);
07652: (new Test("tos006")).ok = (d.toString() instanceof java.lang.String);
07653: summary("toString");
07654: }
07655:
07656: /* ----------------------------------------------------------------- */
07657:
07658: /** Test the {@link com.ibm.icu.math.BigDecimal#unscaledValue} method. */
07659:
07660: public void diagunscaledvalue() {
07661: // just like toBigInteger, but scaly bits are preserved [without dots]
07662: (new Test("uns001")).ok = ((new com.ibm.icu.math.BigDecimal(
07663: "-1")).unscaledValue().toString()).equals("-1");
07664: (new Test("uns002")).ok = ((new com.ibm.icu.math.BigDecimal("0"))
07665: .unscaledValue().toString()).equals("0");
07666: (new Test("uns003")).ok = ((new com.ibm.icu.math.BigDecimal(
07667: "+1")).unscaledValue().toString()).equals("1");
07668: (new Test("uns004")).ok = ((new com.ibm.icu.math.BigDecimal(
07669: "10")).unscaledValue().toString()).equals("10");
07670: (new Test("uns005")).ok = ((new com.ibm.icu.math.BigDecimal(
07671: "1000")).unscaledValue().toString()).equals("1000");
07672: (new Test("uns006")).ok = ((new com.ibm.icu.math.BigDecimal(
07673: "-1E+0")).unscaledValue().toString()).equals("-1");
07674: (new Test("uns007")).ok = ((new com.ibm.icu.math.BigDecimal(
07675: "0E+0")).unscaledValue().toString()).equals("0");
07676: (new Test("uns008")).ok = ((new com.ibm.icu.math.BigDecimal(
07677: "+1E+0")).unscaledValue().toString()).equals("1");
07678: (new Test("uns009")).ok = ((new com.ibm.icu.math.BigDecimal(
07679: "10E+0")).unscaledValue().toString()).equals("10");
07680: (new Test("uns010")).ok = ((new com.ibm.icu.math.BigDecimal(
07681: "1E+3")).unscaledValue().toString()).equals("1000");
07682: (new Test("uns011")).ok = ((new com.ibm.icu.math.BigDecimal(
07683: "0.00")).unscaledValue().toString()).equals("0");
07684: (new Test("uns012")).ok = ((new com.ibm.icu.math.BigDecimal(
07685: "0.01")).unscaledValue().toString()).equals("1");
07686: (new Test("uns013")).ok = ((new com.ibm.icu.math.BigDecimal(
07687: "0.0")).unscaledValue().toString()).equals("0");
07688: (new Test("uns014")).ok = ((new com.ibm.icu.math.BigDecimal(
07689: "0.1")).unscaledValue().toString()).equals("1");
07690: (new Test("uns015")).ok = ((new com.ibm.icu.math.BigDecimal(
07691: "-0.00")).unscaledValue().toString()).equals("0");
07692: (new Test("uns016")).ok = ((new com.ibm.icu.math.BigDecimal(
07693: "-0.01")).unscaledValue().toString()).equals("-1");
07694: (new Test("uns017")).ok = ((new com.ibm.icu.math.BigDecimal(
07695: "-0.0")).unscaledValue().toString()).equals("0");
07696: (new Test("uns018")).ok = ((new com.ibm.icu.math.BigDecimal(
07697: "-0.1")).unscaledValue().toString()).equals("-1");
07698: (new Test("uns019")).ok = ((new com.ibm.icu.math.BigDecimal(
07699: "1.00")).unscaledValue().toString()).equals("100");
07700: (new Test("uns020")).ok = ((new com.ibm.icu.math.BigDecimal(
07701: "1.01")).unscaledValue().toString()).equals("101");
07702: (new Test("uns021")).ok = ((new com.ibm.icu.math.BigDecimal(
07703: "1.0")).unscaledValue().toString()).equals("10");
07704: (new Test("uns022")).ok = ((new com.ibm.icu.math.BigDecimal(
07705: "1.1")).unscaledValue().toString()).equals("11");
07706: (new Test("uns023")).ok = ((new com.ibm.icu.math.BigDecimal(
07707: "-1.00")).unscaledValue().toString()).equals("-100");
07708: (new Test("uns024")).ok = ((new com.ibm.icu.math.BigDecimal(
07709: "-1.01")).unscaledValue().toString()).equals("-101");
07710: (new Test("uns025")).ok = ((new com.ibm.icu.math.BigDecimal(
07711: "-1.0")).unscaledValue().toString()).equals("-10");
07712: (new Test("uns026")).ok = ((new com.ibm.icu.math.BigDecimal(
07713: "-1.1")).unscaledValue().toString()).equals("-11");
07714: (new Test("uns027")).ok = ((new com.ibm.icu.math.BigDecimal(
07715: "-111.111")).unscaledValue().toString())
07716: .equals("-111111");
07717: (new Test("uns028")).ok = ((new com.ibm.icu.math.BigDecimal(
07718: "+111.111")).unscaledValue().toString())
07719: .equals("111111");
07720: summary("unscaledValue");
07721: }
07722:
07723: /* ----------------------------------------------------------------- */
07724:
07725: /** Test the {@link com.ibm.icu.math.BigDecimal#valueOf} method [long and double]. */
07726:
07727: public void diagvalueof() {
07728: boolean flag = false;
07729: java.lang.NumberFormatException e = null;
07730: double dzer;
07731: double dpos;
07732: double dneg;
07733: double dpos5;
07734: double dneg5;
07735: double dmin;
07736: double dmax;
07737: double d;
07738:
07739: // valueOf(long [,scale]) --
07740:
07741: (new Test("val001")).ok = (com.ibm.icu.math.BigDecimal
07742: .valueOf((long) ((byte) -2)).toString()).equals("-2");
07743: (new Test("val002")).ok = (com.ibm.icu.math.BigDecimal
07744: .valueOf((long) ((byte) -1)).toString()).equals("-1");
07745: (new Test("val003")).ok = (com.ibm.icu.math.BigDecimal
07746: .valueOf((long) ((byte) -0)).toString()).equals("0");
07747: (new Test("val004")).ok = (com.ibm.icu.math.BigDecimal
07748: .valueOf((long) ((byte) +1)).toString()).equals("1");
07749: (new Test("val005")).ok = (com.ibm.icu.math.BigDecimal
07750: .valueOf((long) ((byte) +2)).toString()).equals("2");
07751: (new Test("val006")).ok = (com.ibm.icu.math.BigDecimal
07752: .valueOf((long) ((byte) 10)).toString()).equals("10");
07753: (new Test("val007")).ok = (com.ibm.icu.math.BigDecimal
07754: .valueOf((long) ((byte) 11)).toString()).equals("11");
07755: (new Test("val008")).ok = (com.ibm.icu.math.BigDecimal
07756: .valueOf(lmin).toString())
07757: .equals("-9223372036854775808");
07758: (new Test("val009")).ok = (com.ibm.icu.math.BigDecimal
07759: .valueOf(lmax).toString())
07760: .equals("9223372036854775807");
07761: (new Test("val010")).ok = (com.ibm.icu.math.BigDecimal
07762: .valueOf(lneg).toString()).equals("-1");
07763: (new Test("val011")).ok = (com.ibm.icu.math.BigDecimal
07764: .valueOf(lzer).toString()).equals("0");
07765: (new Test("val012")).ok = (com.ibm.icu.math.BigDecimal
07766: .valueOf(lpos).toString()).equals("1");
07767: (new Test("val013")).ok = (com.ibm.icu.math.BigDecimal.valueOf(
07768: lmin, 0).toString()).equals("-9223372036854775808");
07769: (new Test("val014")).ok = (com.ibm.icu.math.BigDecimal.valueOf(
07770: lmax, 0).toString()).equals("9223372036854775807");
07771: (new Test("val015")).ok = (com.ibm.icu.math.BigDecimal.valueOf(
07772: lneg, 0).toString()).equals("-1");
07773: (new Test("val016")).ok = (com.ibm.icu.math.BigDecimal.valueOf(
07774: lpos, 0).toString()).equals("1");
07775:
07776: (new Test("val017")).ok = (com.ibm.icu.math.BigDecimal.valueOf(
07777: lzer, 0).toString()).equals("0");
07778: (new Test("val018")).ok = (com.ibm.icu.math.BigDecimal.valueOf(
07779: lzer, 1).toString()).equals("0.0");
07780: (new Test("val019")).ok = (com.ibm.icu.math.BigDecimal.valueOf(
07781: lzer, 2).toString()).equals("0.00");
07782: (new Test("val020")).ok = (com.ibm.icu.math.BigDecimal.valueOf(
07783: lzer, 3).toString()).equals("0.000");
07784: (new Test("val021")).ok = (com.ibm.icu.math.BigDecimal.valueOf(
07785: lzer, 10).toString()).equals("0.0000000000");
07786:
07787: (new Test("val022")).ok = (com.ibm.icu.math.BigDecimal.valueOf(
07788: lmin, 7).toString()).equals("-922337203685.4775808");
07789: (new Test("val023")).ok = (com.ibm.icu.math.BigDecimal.valueOf(
07790: lmax, 11).toString()).equals("92233720.36854775807");
07791:
07792: try {
07793: checkscale: do {
07794: com.ibm.icu.math.BigDecimal.valueOf((long) 23, -8);
07795: flag = false;
07796: } while (false);
07797: } catch (java.lang.NumberFormatException $127) {
07798: e = $127;
07799: flag = (e.getMessage()).equals("Negative scale: -8");
07800: }/*checkscale*/
07801: (new Test("val100")).ok = flag;
07802:
07803: // valueOf(double) --
07804:
07805: dzer = (double) 0;
07806: dpos = (double) 1;
07807: dpos = dpos / ((double) 10);
07808: dneg = (double) -dpos;
07809: (new Test("val201")).ok = (com.ibm.icu.math.BigDecimal
07810: .valueOf(dneg).toString()).equals("-0.1");
07811: (new Test("val202")).ok = (com.ibm.icu.math.BigDecimal
07812: .valueOf(dzer).toString()).equals("0.0"); // cf. constructor
07813: (new Test("val203")).ok = (com.ibm.icu.math.BigDecimal
07814: .valueOf(dpos).toString()).equals("0.1");
07815: dpos5 = (double) 0.5D;
07816: dneg5 = (double) -dpos5;
07817: (new Test("val204")).ok = (com.ibm.icu.math.BigDecimal
07818: .valueOf(dneg5).toString()).equals("-0.5");
07819: (new Test("val205")).ok = (com.ibm.icu.math.BigDecimal
07820: .valueOf(dpos5).toString()).equals("0.5");
07821: dmin = java.lang.Double.MIN_VALUE;
07822: dmax = java.lang.Double.MAX_VALUE;
07823: (new Test("val206")).ok = (com.ibm.icu.math.BigDecimal
07824: .valueOf(dmin).toString()).equals("4.9E-324");
07825: (new Test("val207")).ok = (com.ibm.icu.math.BigDecimal
07826: .valueOf(dmax).toString())
07827: .equals("1.7976931348623157E+308");
07828:
07829: // nasties
07830: d = (double) 9;
07831: d = d / ((double) 10);
07832: (new Test("val210")).ok = (com.ibm.icu.math.BigDecimal
07833: .valueOf(d).toString()).equals("0.9");
07834: d = d / ((double) 10);
07835: (new Test("val211")).ok = (com.ibm.icu.math.BigDecimal
07836: .valueOf(d).toString()).equals("0.09");
07837: d = d / ((double) 10);
07838: (new Test("val212")).ok = (com.ibm.icu.math.BigDecimal
07839: .valueOf(d).toString()).equals("0.0090");
07840: d = d / ((double) 10);
07841: (new Test("val213")).ok = (com.ibm.icu.math.BigDecimal
07842: .valueOf(d).toString()).equals("9.0E-4");
07843: d = d / ((double) 10);
07844: (new Test("val214")).ok = (com.ibm.icu.math.BigDecimal
07845: .valueOf(d).toString()).equals("8.999999999999999E-5");
07846: d = d / ((double) 10);
07847: (new Test("val215")).ok = (com.ibm.icu.math.BigDecimal
07848: .valueOf(d).toString()).equals("8.999999999999999E-6");
07849: d = d / ((double) 10);
07850: (new Test("val216")).ok = (com.ibm.icu.math.BigDecimal
07851: .valueOf(d).toString()).equals("8.999999999999999E-7");
07852: d = d / ((double) 10);
07853: (new Test("val217")).ok = (com.ibm.icu.math.BigDecimal
07854: .valueOf(d).toString()).equals("8.999999999999999E-8");
07855: d = d / ((double) 10);
07856: (new Test("val218")).ok = (com.ibm.icu.math.BigDecimal
07857: .valueOf(d).toString()).equals("8.999999999999998E-9");
07858:
07859: try {
07860: checkpin: do {
07861: com.ibm.icu.math.BigDecimal
07862: .valueOf(java.lang.Double.POSITIVE_INFINITY);
07863: flag = false;
07864: } while (false);
07865: } catch (java.lang.NumberFormatException $128) {
07866: flag = true;
07867: }/*checkpin*/
07868: (new Test("val301")).ok = flag;
07869: try {
07870: checknin: do {
07871: com.ibm.icu.math.BigDecimal
07872: .valueOf(java.lang.Double.NEGATIVE_INFINITY);
07873: flag = false;
07874: } while (false);
07875: } catch (java.lang.NumberFormatException $129) {
07876: flag = true;
07877: }/*checknin*/
07878: (new Test("val302")).ok = flag;
07879: try {
07880: checknan: do {
07881: com.ibm.icu.math.BigDecimal
07882: .valueOf(java.lang.Double.NaN);
07883: flag = false;
07884: } while (false);
07885: } catch (java.lang.NumberFormatException $130) {
07886: flag = true;
07887: }/*checknan*/
07888: (new Test("val303")).ok = flag;
07889:
07890: summary("valueOf");
07891: }
07892:
07893: /* ----------------------------------------------------------------- */
07894:
07895: /** Test the {@link com.ibm.icu.math.MathContext} class. */
07896:
07897: public void diagmathcontext() {
07898: com.ibm.icu.math.MathContext mccon1;
07899: com.ibm.icu.math.MathContext mccon2;
07900: com.ibm.icu.math.MathContext mccon3;
07901: com.ibm.icu.math.MathContext mccon4;
07902: com.ibm.icu.math.MathContext mcrmc;
07903: com.ibm.icu.math.MathContext mcrmd;
07904: com.ibm.icu.math.MathContext mcrmf;
07905: com.ibm.icu.math.MathContext mcrmhd;
07906: com.ibm.icu.math.MathContext mcrmhe;
07907: com.ibm.icu.math.MathContext mcrmhu;
07908: com.ibm.icu.math.MathContext mcrmun;
07909: com.ibm.icu.math.MathContext mcrmu;
07910: boolean flag = false;
07911: java.lang.IllegalArgumentException e = null;
07912: // these tests are mostly existence checks
07913: (new Test("mcn001")).ok = (com.ibm.icu.math.MathContext.DEFAULT
07914: .getDigits()) == 9;
07915: (new Test("mcn002")).ok = (com.ibm.icu.math.MathContext.DEFAULT
07916: .getForm()) == com.ibm.icu.math.MathContext.SCIENTIFIC;
07917: (new Test("mcn003")).ok = (com.ibm.icu.math.MathContext.DEFAULT
07918: .getForm()) != com.ibm.icu.math.MathContext.ENGINEERING;
07919: (new Test("mcn004")).ok = (com.ibm.icu.math.MathContext.DEFAULT
07920: .getForm()) != com.ibm.icu.math.MathContext.PLAIN;
07921: (new Test("mcn005")).ok = (com.ibm.icu.math.MathContext.DEFAULT
07922: .getLostDigits() ? 1 : 0) == 0;
07923: (new Test("mcn006")).ok = (com.ibm.icu.math.MathContext.DEFAULT
07924: .getRoundingMode()) == com.ibm.icu.math.MathContext.ROUND_HALF_UP;
07925:
07926: (new Test("mcn010")).ok = com.ibm.icu.math.MathContext.ROUND_CEILING >= 0;
07927: (new Test("mcn011")).ok = com.ibm.icu.math.MathContext.ROUND_DOWN >= 0;
07928: (new Test("mcn012")).ok = com.ibm.icu.math.MathContext.ROUND_FLOOR >= 0;
07929: (new Test("mcn013")).ok = com.ibm.icu.math.MathContext.ROUND_HALF_DOWN >= 0;
07930: (new Test("mcn014")).ok = com.ibm.icu.math.MathContext.ROUND_HALF_EVEN >= 0;
07931: (new Test("mcn015")).ok = com.ibm.icu.math.MathContext.ROUND_HALF_UP >= 0;
07932: (new Test("mcn016")).ok = com.ibm.icu.math.MathContext.ROUND_UNNECESSARY >= 0;
07933: (new Test("mcn017")).ok = com.ibm.icu.math.MathContext.ROUND_UP >= 0;
07934:
07935: mccon1 = new com.ibm.icu.math.MathContext(111);
07936: (new Test("mcn021")).ok = (mccon1.getDigits()) == 111;
07937: (new Test("mcn022")).ok = (mccon1.getForm()) == com.ibm.icu.math.MathContext.SCIENTIFIC;
07938: (new Test("mcn023")).ok = (mccon1.getLostDigits() ? 1 : 0) == 0;
07939: (new Test("mcn024")).ok = (mccon1.getRoundingMode()) == com.ibm.icu.math.MathContext.ROUND_HALF_UP;
07940:
07941: mccon2 = new com.ibm.icu.math.MathContext(78,
07942: com.ibm.icu.math.MathContext.ENGINEERING);
07943: (new Test("mcn031")).ok = (mccon2.getDigits()) == 78;
07944: (new Test("mcn032")).ok = (mccon2.getForm()) == com.ibm.icu.math.MathContext.ENGINEERING;
07945: (new Test("mcn033")).ok = (mccon2.getLostDigits() ? 1 : 0) == 0;
07946: (new Test("mcn034")).ok = (mccon2.getRoundingMode()) == com.ibm.icu.math.MathContext.ROUND_HALF_UP;
07947:
07948: mccon3 = new com.ibm.icu.math.MathContext(5,
07949: com.ibm.icu.math.MathContext.PLAIN, true);
07950: (new Test("mcn041")).ok = (mccon3.getDigits()) == 5;
07951: (new Test("mcn042")).ok = (mccon3.getForm()) == com.ibm.icu.math.MathContext.PLAIN;
07952: (new Test("mcn043")).ok = (mccon3.getLostDigits() ? 1 : 0) == 1;
07953: (new Test("mcn044")).ok = (mccon3.getRoundingMode()) == com.ibm.icu.math.MathContext.ROUND_HALF_UP;
07954:
07955: mccon4 = new com.ibm.icu.math.MathContext(0,
07956: com.ibm.icu.math.MathContext.SCIENTIFIC, false,
07957: com.ibm.icu.math.MathContext.ROUND_FLOOR);
07958: (new Test("mcn051")).ok = (mccon4.getDigits()) == 0;
07959: (new Test("mcn052")).ok = (mccon4.getForm()) == com.ibm.icu.math.MathContext.SCIENTIFIC;
07960: (new Test("mcn053")).ok = (mccon4.getLostDigits() ? 1 : 0) == 0;
07961: (new Test("mcn054")).ok = (mccon4.getRoundingMode()) == com.ibm.icu.math.MathContext.ROUND_FLOOR;
07962:
07963: (new Test("mcn061")).ok = (mccon1.toString())
07964: .equals("digits=111 form=SCIENTIFIC lostDigits=0 roundingMode=ROUND_HALF_UP");
07965:
07966: (new Test("mcn062")).ok = (mccon2.toString())
07967: .equals("digits=78 form=ENGINEERING lostDigits=0 roundingMode=ROUND_HALF_UP");
07968:
07969: (new Test("mcn063")).ok = (mccon3.toString())
07970: .equals("digits=5 form=PLAIN lostDigits=1 roundingMode=ROUND_HALF_UP");
07971:
07972: (new Test("mcn064")).ok = (mccon4.toString())
07973: .equals("digits=0 form=SCIENTIFIC lostDigits=0 roundingMode=ROUND_FLOOR");
07974:
07975: // complete testing rounding modes round trips
07976: mcrmc = new com.ibm.icu.math.MathContext(0,
07977: com.ibm.icu.math.MathContext.PLAIN, false,
07978: com.ibm.icu.math.MathContext.ROUND_CEILING);
07979: mcrmd = new com.ibm.icu.math.MathContext(0,
07980: com.ibm.icu.math.MathContext.PLAIN, false,
07981: com.ibm.icu.math.MathContext.ROUND_DOWN);
07982: mcrmf = new com.ibm.icu.math.MathContext(0,
07983: com.ibm.icu.math.MathContext.PLAIN, false,
07984: com.ibm.icu.math.MathContext.ROUND_FLOOR);
07985: mcrmhd = new com.ibm.icu.math.MathContext(0,
07986: com.ibm.icu.math.MathContext.PLAIN, false,
07987: com.ibm.icu.math.MathContext.ROUND_HALF_DOWN);
07988: mcrmhe = new com.ibm.icu.math.MathContext(0,
07989: com.ibm.icu.math.MathContext.PLAIN, false,
07990: com.ibm.icu.math.MathContext.ROUND_HALF_EVEN);
07991: mcrmhu = new com.ibm.icu.math.MathContext(0,
07992: com.ibm.icu.math.MathContext.PLAIN, false,
07993: com.ibm.icu.math.MathContext.ROUND_HALF_UP);
07994: mcrmun = new com.ibm.icu.math.MathContext(0,
07995: com.ibm.icu.math.MathContext.PLAIN, false,
07996: com.ibm.icu.math.MathContext.ROUND_UNNECESSARY);
07997: mcrmu = new com.ibm.icu.math.MathContext(0,
07998: com.ibm.icu.math.MathContext.PLAIN, false,
07999: com.ibm.icu.math.MathContext.ROUND_UP);
08000:
08001: (new Test("mcn071")).ok = (mcrmc.toString())
08002: .equals("digits=0 form=PLAIN lostDigits=0 roundingMode=ROUND_CEILING");
08003:
08004: (new Test("mcn072")).ok = (mcrmd.toString())
08005: .equals("digits=0 form=PLAIN lostDigits=0 roundingMode=ROUND_DOWN");
08006:
08007: (new Test("mcn073")).ok = (mcrmf.toString())
08008: .equals("digits=0 form=PLAIN lostDigits=0 roundingMode=ROUND_FLOOR");
08009:
08010: (new Test("mcn074")).ok = (mcrmhd.toString())
08011: .equals("digits=0 form=PLAIN lostDigits=0 roundingMode=ROUND_HALF_DOWN");
08012:
08013: (new Test("mcn075")).ok = (mcrmhe.toString())
08014: .equals("digits=0 form=PLAIN lostDigits=0 roundingMode=ROUND_HALF_EVEN");
08015:
08016: (new Test("mcn076")).ok = (mcrmhu.toString())
08017: .equals("digits=0 form=PLAIN lostDigits=0 roundingMode=ROUND_HALF_UP");
08018:
08019: (new Test("mcn077")).ok = (mcrmun.toString())
08020: .equals("digits=0 form=PLAIN lostDigits=0 roundingMode=ROUND_UNNECESSARY");
08021:
08022: (new Test("mcn078")).ok = (mcrmu.toString())
08023: .equals("digits=0 form=PLAIN lostDigits=0 roundingMode=ROUND_UP");
08024:
08025: // [get methods tested already]
08026:
08027: // errors...
08028:
08029: try {
08030: checkdig: do {
08031: new com.ibm.icu.math.MathContext(-1);
08032: flag = false;
08033: } while (false);
08034: } catch (java.lang.IllegalArgumentException $131) {
08035: e = $131;
08036: flag = (e.getMessage()).equals("Digits too small: -1");
08037: }/*checkdig*/
08038: (new Test("mcn101")).ok = flag;
08039: try {
08040: checkdigbig: do {
08041: new com.ibm.icu.math.MathContext(1000000000);
08042: flag = false;
08043: } while (false);
08044: } catch (java.lang.IllegalArgumentException $132) {
08045: e = $132;
08046: flag = (e.getMessage())
08047: .equals("Digits too large: 1000000000");
08048: }/*checkdigbig*/
08049: (new Test("mcn102")).ok = flag;
08050:
08051: try {
08052: checkform: do {
08053: new com.ibm.icu.math.MathContext(0, 5);
08054: flag = false;
08055: } while (false);
08056: } catch (java.lang.IllegalArgumentException $133) {
08057: e = $133;
08058: flag = (e.getMessage()).equals("Bad form value: 5");
08059: }/*checkform*/
08060: (new Test("mcn111")).ok = flag;
08061: try {
08062: checkformneg: do {
08063: new com.ibm.icu.math.MathContext(0, -1);
08064: flag = false;
08065: } while (false);
08066: } catch (java.lang.IllegalArgumentException $134) {
08067: e = $134;
08068: flag = (e.getMessage()).equals("Bad form value: -1");
08069: }/*checkformneg*/
08070: (new Test("mcn112")).ok = flag;
08071:
08072: // [lostDigits cannot be invalid]
08073:
08074: try {
08075: checkround: do {
08076: new com.ibm.icu.math.MathContext(0,
08077: com.ibm.icu.math.MathContext.PLAIN, false, 12);
08078: flag = false;
08079: } while (false);
08080: } catch (java.lang.IllegalArgumentException $135) {
08081: e = $135;
08082: flag = (e.getMessage())
08083: .equals("Bad roundingMode value: 12");
08084: }/*checkround*/
08085: (new Test("mcn121")).ok = flag;
08086: try {
08087: checkroundneg: do {
08088: new com.ibm.icu.math.MathContext(0,
08089: com.ibm.icu.math.MathContext.PLAIN, false, -1);
08090: flag = false;
08091: } while (false);
08092: } catch (java.lang.IllegalArgumentException $136) {
08093: e = $136;
08094: flag = (e.getMessage())
08095: .equals("Bad roundingMode value: -1");
08096: }/*checkroundneg*/
08097: (new Test("mcn122")).ok = flag;
08098:
08099: summary("MathContext");
08100: }
08101:
08102: /* ----------------------------------------------------------------- */
08103:
08104: /** Test general arithmetic (base operators).
08105: * <p>Unlike the specific method tests, these tests were randomly
08106: * generated by an IBM Object Rexx procedure, then manually corrected
08107: * for known differences from ANSI X3-274. These differences are:
08108: * <ol>
08109: * <li>the trigger point in exponential notation is fixed in ANSI
08110: * X3-274 but varies with DIGITS in Classic and Object Rexx
08111: * <li>some trailing zeros were missing (e.g., 1.3 + 1E-60 should show
08112: * seven trailing zeros)
08113: * <li>the power operator is less accurate in Object Rexx
08114: * <li>ANSI X3-274 [errata 1999] rounds input numbers to DIGITS (rather
08115: * than truncating to DIGITS+1).
08116: * </ol>
08117: */
08118:
08119: public void diagmath() {
08120: com.ibm.icu.math.MathContext def;
08121: def = com.ibm.icu.math.MathContext.DEFAULT;
08122: mathtest(1, def, "-9375284.42", "5516.99832E+27276984",
08123: "5.51699832E+27276987", "-5.51699832E+27276987",
08124: "-5.17234284E+27276994", "-1.69934516E-27276981", "0",
08125: "-9375284.42", "6.79057752E+41");
08126: mathtest(2, def, "-410.832710", "99.3588243E-502740862",
08127: "-410.832710", "-410.832710", "-4.08198550E-502740858",
08128: "-4.13483868E+502740862", "", "", "1.36977786E+26");
08129: mathtest(3, def, "80025.2340", "-8.03097581", "80017.2030",
08130: "80033.2650", "-642680.718", "-9964.57167", "-9964",
08131: "4.59102916", "5.94544517E-40");
08132: mathtest(4, def, "81052020.2", "-464525495", "-383473475",
08133: "545577515", "-3.76507298E+16", "-0.17448347", "0",
08134: "81052020.2", "");
08135: mathtest(5, def, "715.069294E-26923151",
08136: "85.4404128E+796388557", "8.54404128E+796388558",
08137: "-8.54404128E+796388558", "6.10958157E+769465410",
08138: "8.36921628E-823311708", "0", "7.15069294E-26923149",
08139: "4.88802213E-242308334");
08140: mathtest(6, def, "-21971575.0E+31454441",
08141: "-70944960.3E+111238221", "-7.09449603E+111238228",
08142: "7.09449603E+111238228", "1.55877252E+142692677",
08143: "3.09698884E-79783781", "0", "-2.19715750E+31454448",
08144: "-4.04549502E-220181139");
08145: mathtest(7, def, "682.25316", "54470185.6", "54470867.9",
08146: "-54469503.4", "3.71624563E+10", "0.0000125252586",
08147: "0", "682.25316", "3.48578699E+154365541");
08148: mathtest(8, def, "-257586757.", "2082888.71", "-255503868",
08149: "-259669646", "-5.36524548E+14", "-123.668036", "-123",
08150: "-1391445.67", "-1.26879515E+17519020");
08151: mathtest(9, def, "319577540.E+242599761", "60.7124561",
08152: "3.19577540E+242599769", "3.19577540E+242599769",
08153: "1.94023374E+242599771", "5.26378869E+242599767", "",
08154: "", "");
08155: mathtest(10, def, "-13769977.0", "24371.3381", "-13745605.7",
08156: "-13794348.3", "-3.35592765E+11", "-565.007015",
08157: "-565", "-170.9735", "-8.73734001E+173982");
08158: mathtest(11, def, "-475.434972E-725464311",
08159: "-3.22214066E-865476836", "-4.75434972E-725464309",
08160: "-4.75434972E-725464309", "", "1.47552519E+140012527",
08161: "", "", "");
08162: mathtest(12, def, "842.01250", "197199893", "197200735",
08163: "-197199051", "1.66044775E+11", "0.00000426984258",
08164: "0", "842.01250", "7.00674164E+576872502");
08165: mathtest(13, def, "572.173103E+280128428", "-7140.19428",
08166: "5.72173103E+280128430", "5.72173103E+280128430",
08167: "-4.08542712E+280128434", "-8.01341085E+280128426", "",
08168: "", "");
08169: mathtest(14, def, "674235.954E+476135291", "9684.82245",
08170: "6.74235954E+476135296", "6.74235954E+476135296",
08171: "6.52985550E+476135300", "6.96177919E+476135292", "",
08172: "", "");
08173: mathtest(15, def, "-360557.921E+437116514", "930428850",
08174: "-3.60557921E+437116519", "-3.60557921E+437116519",
08175: "-3.35473492E+437116528", "-3.87517993E+437116510", "",
08176: "", "");
08177: mathtest(16, def, "957165918E-394595705",
08178: "1676.59073E-829618944", "9.57165918E-394595697",
08179: "9.57165918E-394595697", "", "5.70900161E+435023244",
08180: "", "", "9.16166595E-789191393");
08181: mathtest(17, def, "-2610864.40", "31245912.7", "28635048.3",
08182: "-33856777.1", "-8.15788411E+13", "-0.0835585897", "0",
08183: "-2610864.40", "-3.12008905E+200498284");
08184: mathtest(18, def, "959.548461", "98.994577E+776775426",
08185: "9.89945770E+776775427", "-9.89945770E+776775427",
08186: "9.49900940E+776775430", "9.69293965E-776775426", "0",
08187: "959.548461", "6.61712185E+29");
08188: mathtest(19, def, "-41085.0268", "3115477.61", "3074392.58",
08189: "-3156562.64", "-1.27999481E+11", "-0.0131873927", "0",
08190: "-41085.0268", "4.73844173E+14373829");
08191: mathtest(20, def, "-723420285.", "2681660.35", "-720738625",
08192: "-726101945", "-1.93996749E+15", "-269.765813", "-269",
08193: "-2053650.85", "4.14324113E+23757873");
08194: mathtest(21, def, "63542018.0E-817732230", "-8836243.22",
08195: "-8836243.22", "8836243.22", "-5.61472726E-817732216",
08196: "-7.19106711E-817732230", "0", "6.35420180E-817732223",
08197: "");
08198: mathtest(22, def, "-96051.7108", "-291201.955", "-387253.666",
08199: "195150.244", "2.79704460E+10", "0.329845694", "0",
08200: "-96051.7108", "3.53617153E-1450916");
08201: mathtest(23, def, "108490.853", "91685996.5", "91794487.4",
08202: "-91577505.7", "9.94709197E+12", "0.00118328706", "0",
08203: "108490.853", "6.98124265E+461675038");
08204: mathtest(24, def, "-27489.1735", "-9835835.4E-506411649",
08205: "-27489.1735", "-27489.1735", "2.70378986E-506411638",
08206: "2.79479804E+506411646", "", "", "4.05866472E-45");
08207: mathtest(25, def, "-89220406.6", "993391.008E-611041175",
08208: "-89220406.6", "-89220406.6", "-8.86307496E-611041162",
08209: "-8.98139865E+611041176", "", "", "3.19625913E+79");
08210: mathtest(26, def, "4.75502020", "-17089144.9", "-17089140.2",
08211: "17089149.7", "-81259229.2", "-2.78247989E-7", "0",
08212: "4.75502020", "1.0630191E-11571955");
08213: mathtest(27, def, "68027916.2", "-796883.839", "67231032.4",
08214: "68824800.0", "-5.42103470E+13", "-85.3674185", "-85",
08215: "292789.885", "8.29415374E-6241744");
08216: mathtest(28, def, "-8.01969439E+788605478", "92154156.0",
08217: "-8.01969439E+788605478", "-8.01969439E+788605478",
08218: "-7.39048168E+788605486", "-8.70247717E+788605470", "",
08219: "", "");
08220: mathtest(29, def, "-8012.98341", "96188.8651", "88175.8817",
08221: "-104201.849", "-770759780", "-0.0833046881", "0",
08222: "-8012.98341", "-1.16010156E+375502");
08223: mathtest(30, def, "21761476E+592330677", "-9.70744506",
08224: "2.17614760E+592330684", "2.17614760E+592330684",
08225: "-2.11248333E+592330685", "-2.24173053E+592330683", "",
08226: "", "");
08227: mathtest(31, def, "-9840778.51", "-17907.219", "-9858685.73",
08228: "-9822871.29", "1.76220976E+11", "549.542534", "549",
08229: "-9715.279", "-6.62997437E-125225");
08230: mathtest(32, def, "-4.1097614", "-819.225776E-145214751",
08231: "-4.10976140", "-4.10976140", "3.36682247E-145214748",
08232: "5.01664074E+145214748", "", "", "0.0000122876018");
08233: mathtest(33, def, "-448.880985", "-394.087374E-442511435",
08234: "-448.880985", "-448.880985", "1.76898329E-442511430",
08235: "1.13903925E+442511435", "", "", "2.46306099E-11");
08236: mathtest(34, def, "779.445304E+882688544", "-797868519",
08237: "7.79445304E+882688546", "7.79445304E+882688546",
08238: "-6.21894870E+882688555", "-9.7690946E+882688537", "",
08239: "", "");
08240: mathtest(35, def, "799995477", "-6.23675208E+156309440",
08241: "-6.23675208E+156309440", "6.23675208E+156309440",
08242: "-4.98937346E+156309449", "-1.28271169E-156309432",
08243: "0", "799995477", "3.81482667E-54");
08244: mathtest(36, def, "-51932.8170", "591840275E-278480289",
08245: "-51932.8170", "-51932.8170", "-3.07359327E-278480276",
08246: "-8.7748028E+278480284", "", "", "1.96178443E+28");
08247: mathtest(37, def, "70.3552392", "-4228656.73", "-4228586.38",
08248: "4228727.09", "-297508156", "-0.0000166377277", "0",
08249: "70.3552392", "9.14742382E-7811584");
08250: mathtest(38, def, "1588359.34", "-12232799.2", "-10644439.9",
08251: "13821158.5", "-1.94300809E+13", "-0.129844307", "0",
08252: "1588359.34", "1.56910086E-75854960");
08253: mathtest(39, def, "2842.16206", "-3.23234345", "2838.92972",
08254: "2845.39440", "-9186.84392", "-879.288388", "-879",
08255: "0.93216745", "4.35565514E-11");
08256: mathtest(40, def, "29960.2305", "45.2735747E-95205475",
08257: "29960.2305", "29960.2305", "1.35640673E-95205469",
08258: "6.61759773E+95205477", "", "", "2.413936E+22");
08259: mathtest(41, def, "2916565.77", "1151935.43E-787118724",
08260: "2916565.77", "2916565.77", "3.35969544E-787118712",
08261: "2.53188303E+787118724", "", "", "2916565.77");
08262: mathtest(42, def, "-52723012.9E-967143787", "79.4088237",
08263: "79.4088237", "-79.4088237", "-4.18667244E-967143778",
08264: "-6.63944011E-967143782", "0",
08265: "-5.27230129E-967143780", "");
08266: mathtest(43, def, "-167473465", "793646.597", "-166679819",
08267: "-168267112", "-1.32914746E+14", "-211.017682", "-211",
08268: "-14033.033", "-1.19053789E+6526910");
08269: mathtest(44, def, "-31769071.0", "133.4360", "-31768937.6",
08270: "-31769204.4", "-4.23913776E+9", "-238084.707",
08271: "-238084", "-94.3760", "-5.84252432E+997");
08272: mathtest(45, def, "45960.6383", "-93352.7468", "-47392.1085",
08273: "139313.385", "-4.29055183E+9", "-0.492333004", "0",
08274: "45960.6383", "1.88335323E-435248");
08275: mathtest(46, def, "606.175648", "5.28528458E-981983620",
08276: "606.175648", "606.175648", "3.20381081E-981983617",
08277: "1.14691203E+981983622", "", "", "8.18450516E+13");
08278: mathtest(47, def, "171578.617E+643006110", "-407774.293",
08279: "1.71578617E+643006115", "1.71578617E+643006115",
08280: "-6.99653492E+643006120", "-4.20768597E+643006109", "",
08281: "", "");
08282: mathtest(48, def, "-682286332.", "-464.871699", "-682286797",
08283: "-682285867", "3.17175606E+11", "1467687.39",
08284: "1467687", "-182.709787", "-1.6050843E-4108");
08285: mathtest(49, def, "492088.428", "653.72170", "492742.150",
08286: "491434.706", "321688884", "752.74911", "752",
08287: "489.70960", "3.94658596E+3722");
08288: mathtest(50, def, "74303782.5", "1141.68058", "74304924.2",
08289: "74302640.8", "8.48311855E+10", "65082.812", "65082",
08290: "926.99244", "4.94849869E+8988");
08291: mathtest(51, def, "74.7794084E+119375329", "-34799355.6",
08292: "7.47794084E+119375330", "7.47794084E+119375330",
08293: "-2.60227522E+119375338", "-2.14887337E+119375323", "",
08294: "", "");
08295: mathtest(52, def, "-9432.08369", "33735.5058", "24303.4221",
08296: "-43167.5895", "-318196114", "-0.279589218", "0",
08297: "-9432.08369", "2.309567E+134087");
08298: mathtest(53, def, "4249198.78E-112433155", "418673051.",
08299: "418673051", "-418673051", "1.77902502E-112433140",
08300: "1.01492054E-112433157", "0", "4.24919878E-112433149",
08301: "");
08302: mathtest(54, def, "-2960933.02", "-207933.38", "-3168866.40",
08303: "-2752999.64", "6.15676811E+11", "14.2398158", "14",
08304: "-49865.70", "-2.75680397E-1345624");
08305: mathtest(55, def, "29317.7519E+945600035", "1.43555750",
08306: "2.93177519E+945600039", "2.93177519E+945600039",
08307: "4.20873186E+945600039", "2.04225549E+945600039", "",
08308: "", "2.93177519E+945600039");
08309: mathtest(56, def, "-51.1693770", "-638055.414", "-638106.583",
08310: "638004.245", "32648898.0", "0.0000801958198", "0",
08311: "-51.1693770", "-3.48266075E-1090443");
08312: mathtest(57, def, "-756343055.", "-68.9248344E+217100975",
08313: "-6.89248344E+217100976", "6.89248344E+217100976",
08314: "5.21308198E+217100985", "1.09734475E-217100968", "0",
08315: "-756343055", "-7.06265897E-63");
08316: mathtest(58, def, "2538.80406E+694185197", "-3386499.65",
08317: "2.53880406E+694185200", "2.53880406E+694185200",
08318: "-8.59765906E+694185206", "-7.49683839E+694185193", "",
08319: "", "");
08320: mathtest(59, def, "-54344.0672", "-8086.45235", "-62430.5196",
08321: "-46257.6149", "439450710", "6.72038427", "6",
08322: "-5825.35310", "3.62916861E-38289");
08323: mathtest(60, def, "3.31600054", "217481648", "217481651",
08324: "-217481645", "721169262", "1.5247266E-8", "0",
08325: "3.31600054", "3.73134969E+113224119");
08326: mathtest(61, def, "681832.671", "320341.161E+629467560",
08327: "3.20341161E+629467565", "-3.20341161E+629467565",
08328: "2.18419069E+629467571", "2.12845789E-629467560", "0",
08329: "681832.671", "3.16981139E+17");
08330: mathtest(62, def, "832689481", "348040024E-882122501",
08331: "832689481", "832689481", "2.89809267E-882122484",
08332: "2.3925107E+882122501", "", "", "5.77363381E+26");
08333: mathtest(63, def, "14.5512326E+257500811",
08334: "60.9979577E-647314724", "1.45512326E+257500812",
08335: "1.45512326E+257500812", "8.87595471E-389813911",
08336: "2.38552784E+904815534", "", "", "");
08337: mathtest(64, def, "-901.278844", "449461667.", "449460766",
08338: "-449462568", "-4.05090292E+11", "-0.00000200524074",
08339: "0", "-901.278844", "");
08340: mathtest(65, def, "-5.32627675", "-738860216E-238273224",
08341: "-5.32627675", "-5.32627675", "3.93537399E-238273215",
08342: "7.20877459E+238273215", "", "", "-0.00000822306838");
08343: mathtest(66, def, "-505383463.", "3.18756328", "-505383460",
08344: "-505383466", "-1.61094177E+9", "-158548527",
08345: "-158548527", "-0.23671144", "-1.29081226E+26");
08346: mathtest(67, def, "769241.44E-720927320", "-145382631.",
08347: "-145382631", "145382631", "-1.11834344E-720927306",
08348: "-5.29115091E-720927323", "0", "7.6924144E-720927315",
08349: "");
08350: mathtest(68, def, "-6.45038910", "56736.4411E+440937167",
08351: "5.67364411E+440937171", "-5.67364411E+440937171",
08352: "-3.65972121E+440937172", "-1.13690407E-440937171",
08353: "0", "-6.45038910", "72030.3421");
08354: mathtest(69, def, "58.4721075", "-712186829", "-712186771",
08355: "712186887", "-4.16430648E+10", "-8.21022028E-8", "0",
08356: "58.4721075", "");
08357: mathtest(70, def, "8244.08357", "245.302828E+652007959",
08358: "2.45302828E+652007961", "-2.45302828E+652007961",
08359: "2.02229701E+652007965", "3.36077804E-652007958", "0",
08360: "8244.08357", "67964913.9");
08361: mathtest(71, def, "45.5361397", "-76579063.9", "-76579018.4",
08362: "76579109.4", "-3.48711495E+9", "-5.94629098E-7", "0",
08363: "45.5361397", "3.98335374E-126995367");
08364: mathtest(72, def, "594420.54E+685263039", "-952420.179",
08365: "5.94420540E+685263044", "5.94420540E+685263044",
08366: "-5.66138117E+685263050", "-6.24115861E+685263038", "",
08367: "", "");
08368: mathtest(73, def, "-841310701.", "9398110.4", "-831912591",
08369: "-850708811", "-7.90673085E+15", "-89.5191337", "-89",
08370: "-4878875.4", "1.30001466E+83877722");
08371: mathtest(74, def, "904392146E-140100276", "168116093.",
08372: "168116093", "-168116093", "1.52042874E-140100259",
08373: "5.37956914E-140100276", "0", "9.04392146E-140100268",
08374: "");
08375: mathtest(75, def, "-907324792E+685539670", "-15.6902171",
08376: "-9.07324792E+685539678", "-9.07324792E+685539678",
08377: "1.42361230E+685539680", "5.78274211E+685539677", "",
08378: "", "");
08379: mathtest(76, def, "987013606.", "-26818.3572E+560907442",
08380: "-2.68183572E+560907446", "2.68183572E+560907446",
08381: "-2.64700834E+560907455", "-3.68036565E-560907438",
08382: "0", "987013606", "1.0399934E-27");
08383: mathtest(77, def, "-741317564", "630.241530E-212782946",
08384: "-741317564", "-741317564", "-4.67209116E-212782935",
08385: "-1.1762436E+212782952", "", "", "1.65968527E+53");
08386: mathtest(78, def, "61867907.2", "-139204670", "-77336763",
08387: "201072577", "-8.61230161E+15", "-0.444438446", "0",
08388: "61867907.2", "");
08389: mathtest(79, def, "-273.622743E+531282717", "-4543.68684",
08390: "-2.73622743E+531282719", "-2.73622743E+531282719",
08391: "1.24325606E+531282723", "6.02204229E+531282715", "",
08392: "", "");
08393: mathtest(80, def, "-383588949.", "-428640583.", "-812229532",
08394: "45051634", "1.64421791E+17", "0.89489648", "0",
08395: "-383588949", "");
08396: mathtest(81, def, "-56182.2686", "32.7741649", "-56149.4944",
08397: "-56215.0428", "-1841326.94", "-1714.22426", "-1714",
08398: "-7.3499614", "-5.45476402E+156");
08399: mathtest(82, def, "-6366384.30", "332014.980", "-6034369.32",
08400: "-6698399.28", "-2.11373496E+12", "-19.1749911", "-19",
08401: "-58099.680", "-3.05392399E+2258994");
08402: mathtest(83, def, "-1.27897702", "-8213776.03E-686519123",
08403: "-1.27897702", "-1.27897702", "1.05052308E-686519116",
08404: "1.55711212E+686519116", "", "", "0.139668371");
08405: mathtest(84, def, "65.4059036", "401162145E+884155506",
08406: "4.01162145E+884155514", "-4.01162145E+884155514",
08407: "2.62383726E+884155516", "1.63041066E-884155513", "0",
08408: "65.4059036", "18300704.1");
08409: mathtest(85, def, "-20630916.8", "158987411.E-480500612",
08410: "-20630916.8", "-20630916.8", "-3.28005605E-480500597",
08411: "-1.29764468E+480500611", "", "", "4.25634728E+14");
08412: mathtest(86, def, "-4.72705853", "-97626742.4", "-97626747.1",
08413: "97626737.7", "461487325", "4.84197097E-8", "0",
08414: "-4.72705853", "2.92654449E-65858120");
08415: mathtest(87, def, "8.43528169", "-4573.45752", "-4565.02224",
08416: "4581.89280", "-38578.4025", "-0.00184439927", "0",
08417: "8.43528169", "8.84248688E-4236");
08418: mathtest(88, def, "1.91075189", "-704247089.", "-704247087",
08419: "704247091", "-1.34564146E+9", "-2.71318394E-9", "0",
08420: "1.91075189", "6.84547494E-198037309");
08421: mathtest(89, def, "31997198E-551746308", "326.892584",
08422: "326.892584", "-326.892584", "1.04596467E-551746298",
08423: "9.78829119E-551746304", "0", "3.1997198E-551746301",
08424: "");
08425: mathtest(90, def, "127589.213", "84184304.", "84311893.2",
08426: "-84056714.8", "1.07410091E+13", "0.00151559385", "0",
08427: "127589.213", "2.87917042E+429829394");
08428: mathtest(91, def, "714494248", "-7025063.59", "707469185",
08429: "721519312", "-5.01936753E+15", "-101.706446", "-101",
08430: "4962825.41", "1.65018516E-62199908");
08431: mathtest(92, def, "-52987680.2E+279533503", "-42014114.8",
08432: "-5.29876802E+279533510", "-5.29876802E+279533510",
08433: "2.22623048E+279533518", "1.26118759E+279533503", "",
08434: "", "");
08435: mathtest(93, def, "-8795.0513", "-225294.394E-884414238",
08436: "-8795.05130", "-8795.05130", "1.98147575E-884414229",
08437: "3.90380388E+884414236", "", "", "1.2927759E-8");
08438: mathtest(94, def, "83280.1394", "161566354.", "161649634",
08439: "-161483074", "1.34552685E+13", "0.000515454718", "0",
08440: "83280.1394", "5.30774809E+794993940");
08441: mathtest(95, def, "112.877897", "-9.96481666", "102.913080",
08442: "122.842714", "-1124.80755", "-11.3276441", "-11",
08443: "3.26491374", "2.97790545E-21");
08444: mathtest(96, def, "-572542.121E+847487397", "433.843420",
08445: "-5.72542121E+847487402", "-5.72542121E+847487402",
08446: "-2.48393632E+847487405", "-1.3196976E+847487400", "",
08447: "", "");
08448: mathtest(97, def, "4709649.89", "20949266.4", "25658916.3",
08449: "-16239616.5", "9.86637102E+13", "0.224812163", "0",
08450: "4709649.89", "4.85293644E+139794213");
08451: mathtest(98, def, "-9475.19322", "-30885.2475E+584487341",
08452: "-3.08852475E+584487345", "3.08852475E+584487345",
08453: "2.92643688E+584487349", "3.06787026E-584487342", "0",
08454: "-9475.19322", "-1.17553557E-12");
08455: mathtest(99, def, "-213230447.", "864.815822E+127783046",
08456: "8.64815822E+127783048", "-8.64815822E+127783048",
08457: "-1.84405064E+127783057", "-2.46561686E-127783041",
08458: "0", "-213230447", "-9.11261361E+74");
08459: mathtest(100, def, "-89.1168786E+403375873", "6464.05744",
08460: "-8.91168786E+403375874", "-8.91168786E+403375874",
08461: "-5.76056622E+403375878", "-1.37865233E+403375871", "",
08462: "", "");
08463: mathtest(101, def, "61774.4958", "-14000.7706", "47773.7252",
08464: "75775.2664", "-864890545", "-4.41222112", "-4",
08465: "5771.4134", "7.59030407E-67077");
08466: mathtest(102, def, "1.60731414", "7.04330293E-427033419",
08467: "1.60731414", "1.60731414", "1.13208004E-427033418",
08468: "2.28204602E+427033418", "", "", "27.7143921");
08469: mathtest(103, def, "7955012.51", "-230117662.", "-222162650",
08470: "238072675", "-1.83058888E+15", "-0.0345693261", "0",
08471: "7955012.51", "");
08472: mathtest(104, def, "4086661.08", "1.77621994", "4086662.86",
08473: "4086659.30", "7258808.90", "2300762.98", "2300762",
08474: "1.73840572", "1.67007988E+13");
08475: mathtest(105, def, "-610.076931", "-207.658306", "-817.735237",
08476: "-402.418625", "126687.542", "2.93788841", "2",
08477: "-194.760319", "4.36518377E-580");
08478: mathtest(106, def, "-98.6353697", "-99253.3899E-716309653",
08479: "-98.6353697", "-98.6353697", "9.78989481E-716309647",
08480: "9.93773309E+716309649", "", "", "1.14729007E-20");
08481: mathtest(107, def, "-959923730", "409.125542E-900295528",
08482: "-959923730", "-959923730", "-3.92729316E-900295517",
08483: "-2.3462816E+900295534", "", "", "8.49076677E+35");
08484: mathtest(108, def, "379965133", "-8.15869657", "379965125",
08485: "379965141", "-3.10002023E+9", "-46571793.6",
08486: "-46571793", "5.19214999", "2.30170697E-69");
08487: mathtest(109, def, "833.646797", "1389499.46E-443407251",
08488: "833.646797", "833.646797", "1.15835177E-443407242",
08489: "5.99961944E+443407247", "", "", "833.646797");
08490: mathtest(110, def, "2314933.4E-646489194", "-7401538.17",
08491: "-7401538.17", "7401538.17", "-1.71340679E-646489181",
08492: "-3.12763826E-646489195", "0", "2.3149334E-646489188",
08493: "");
08494: mathtest(111, def, "808525347", "-5959.74667E+58232168",
08495: "-5.95974667E+58232171", "5.95974667E+58232171",
08496: "-4.81860624E+58232180", "-1.35664382E-58232163", "0",
08497: "808525347", "3.5796302E-54");
08498: mathtest(112, def, "-17220490.6E+726428704", "19.9855688",
08499: "-1.72204906E+726428711", "-1.72204906E+726428711",
08500: "-3.44161300E+726428712", "-8.61646259E+726428709", "",
08501: "", "");
08502: mathtest(113, def, "59015.9705", "-72070405.4E+322957279",
08503: "-7.20704054E+322957286", "7.20704054E+322957286",
08504: "-4.25330492E+322957291", "-8.18865527E-322957283",
08505: "0", "59015.9705", "4.01063488E-34");
08506: mathtest(114, def, "16411470E+578192008",
08507: "497470.005E-377473621", "1.64114700E+578192015",
08508: "1.64114700E+578192015", "8.16421406E+200718399",
08509: "3.29898684E+955665630", "", "", "");
08510: mathtest(115, def, "-107.353544E+609689808",
08511: "-659.50136E-456711743", "-1.07353544E+609689810",
08512: "-1.07353544E+609689810", "7.07998083E+152978069", "",
08513: "", "", "");
08514: mathtest(116, def, "786.134163", "-53.0292275E-664419768",
08515: "786.134163", "786.134163", "-4.16880874E-664419764",
08516: "-1.48245449E+664419769", "", "", "3.33055532E-15");
08517: mathtest(117, def, "23.5414714", "5000786.91", "5000810.45",
08518: "-5000763.37", "117725882", "0.0000047075534", "0",
08519: "23.5414714", "4.4895618E+6860247");
08520: mathtest(118, def, "-69775.6113", "561292120.", "561222344",
08521: "-561361896", "-3.91645008E+13", "-0.000124312473",
08522: "0", "-69775.6113", "");
08523: mathtest(119, def, "919043.871", "-71606613.7", "-70687569.8",
08524: "72525657.6", "-6.58096194E+13", "-0.0128346227", "0",
08525: "919043.871", "3.05862429E-427014317");
08526: mathtest(120, def, "-27667.1915", "-293455.107E-789181924",
08527: "-27667.1915", "-27667.1915", "8.11907864E-789181915",
08528: "9.42808315E+789181922", "", "", "-4.72176938E-14");
08529: mathtest(121, def, "-908603625.", "-982.409273E+449441134",
08530: "-9.82409273E+449441136", "9.82409273E+449441136",
08531: "8.92620627E+449441145", "9.2487281E-449441129", "0",
08532: "-908603625", "2.60768632E-90");
08533: mathtest(122, def, "847.113351", "5.71511268", "852.828464",
08534: "841.398238", "4841.34825", "148.223386", "148",
08535: "1.27667436", "3.69529538E+17");
08536: mathtest(123, def, "-992140475", "3.82918218", "-992140471",
08537: "-992140479", "-3.79908663E+9", "-259099836",
08538: "-259099836", "-0.14787752", "9.68930595E+35");
08539: mathtest(124, def, "-12606437.5", "268123145E+362798858",
08540: "2.68123145E+362798866", "-2.68123145E+362798866",
08541: "-3.38007767E+362798873", "-4.70173416E-362798860",
08542: "0", "-12606437.5", "-2.00344362E+21");
08543: mathtest(125, def, "3799470.64", "-264.703992", "3799205.94",
08544: "3799735.34", "-1.00573505E+9", "-14353.6583",
08545: "-14353", "174.242824", "2.3625466E-1744");
08546: mathtest(126, def, "-8.11070247", "-931284056.E-654288974",
08547: "-8.11070247", "-8.11070247", "7.55336789E-654288965",
08548: "8.70916067E+654288965", "", "", "-6.58375662E-9");
08549: mathtest(127, def, "-242660177.", "-6.09832715E-943742415",
08550: "-242660177", "-242660177", "1.47982115E-943742406",
08551: "3.97912692E+943742422", "", "", "4.89788901E-51");
08552: mathtest(128, def, "76.1463803", "-45.6758006E-636907996",
08553: "76.1463803", "76.1463803", "-3.47804688E-636907993",
08554: "-1.66710554E+636907996", "", "", "3.90619287E-10");
08555: mathtest(129, def, "761185.862", "-70878470.9E+221214712",
08556: "-7.08784709E+221214719", "7.08784709E+221214719",
08557: "-5.39516900E+221214725", "-1.07393099E-221214714",
08558: "0", "761185.862", "6.75406144E-42");
08559: mathtest(130, def, "6203606.54", "-195.92748E-833512061",
08560: "6203606.54", "6203606.54", "-1.21545700E-833512052",
08561: "-3.1662769E+833512065", "", "", "2.59843292E-14");
08562: mathtest(131, def, "-163274837.", "95.0448550E+887876533",
08563: "9.50448550E+887876534", "-9.50448550E+887876534",
08564: "-1.55184332E+887876543", "-1.71787139E-887876527",
08565: "0", "-163274837", "1.34645731E+82");
08566: mathtest(132, def, "2.38638190", "-807986179.", "-807986177",
08567: "807986181", "-1.92816359E+9", "-2.95349347E-9", "0",
08568: "2.38638190", "1.19029305E-305208656");
08569: mathtest(133, def, "-109022296E-811981158", "7.19685680",
08570: "7.19685680", "-7.19685680", "-7.84617852E-811981150",
08571: "-1.51485988E-811981151", "0",
08572: "-1.09022296E-811981150", "");
08573: mathtest(134, def, "-559250.780E-273710421", "-393780811.",
08574: "-393780811", "393780811", "2.20222226E-273710407",
08575: "1.42020831E-273710424", "0", "-5.59250780E-273710416",
08576: "");
08577: mathtest(135, def, "-88021.9966E+555334642",
08578: "7599686.64E+818884053", "7.59968664E+818884059",
08579: "-7.59968664E+818884059", "", "-1.15823192E-263549413",
08580: "0", "-8.80219966E+555334646", "");
08581: mathtest(136, def, "194.317648E-197450009", "-930.979064",
08582: "-930.979064", "930.979064", "-1.80905662E-197450004",
08583: "-2.08723972E-197450010", "0", "1.94317648E-197450007",
08584: "");
08585: mathtest(137, def, "9495479.65", "7405697.96", "16901177.6",
08586: "2089781.69", "7.03206543E+13", "1.28218565", "1",
08587: "2089781.69", "1.0135446E+51673383");
08588: mathtest(138, def, "-1656.28925", "-163050511E-682882380",
08589: "-1656.28925", "-1656.28925", "2.70058809E-682882369",
08590: "1.01581359E+682882375", "", "", "3.64525265E-7");
08591: mathtest(139, def, "95581.3784E+64262149", "-99.2879365",
08592: "9.55813784E+64262153", "9.55813784E+64262153",
08593: "-9.49007783E+64262155", "-9.62668596E+64262151", "",
08594: "", "");
08595: mathtest(140, def, "643761.452", "3.73446939", "643765.186",
08596: "643757.718", "2404107.44", "172383.647", "172383",
08597: "2.41514363", "1.71751236E+23");
08598: mathtest(141, def, "7960.49866E-129827423", "3220.22850",
08599: "3220.22850", "-3220.22850", "2.56346247E-129827416",
08600: "2.47202913E-129827423", "0", "7.96049866E-129827420",
08601: "");
08602: mathtest(142, def, "-6356.64112E-707203818", "1805054.98",
08603: "1805054.98", "-1805054.98", "-1.14740867E-707203808",
08604: "-3.52157756E-707203821", "0",
08605: "-6.35664112E-707203815", "");
08606: mathtest(143, def, "2.3904042", "8476.52006", "8478.91046",
08607: "-8474.12966", "20262.3092", "0.000282003013", "0",
08608: "2.3904042", "2.00251752E+3208");
08609: mathtest(144, def, "-713298.658", "-957.782729", "-714256.441",
08610: "-712340.875", "683185135", "744.739528", "744",
08611: "-708.307624", "3.68122321E-5608");
08612: mathtest(145, def, "607779233.E-820497365",
08613: "-20.1188742E-857318323", "6.07779233E-820497357",
08614: "6.07779233E-820497357", "", "-3.02094057E+36820965",
08615: "", "", "");
08616: mathtest(146, def, "-205888251", "-908.792922E+250680613",
08617: "-9.08792922E+250680615", "9.08792922E+250680615",
08618: "1.87109785E+250680624", "2.26551336E-250680608", "0",
08619: "-205888251", "-1.5042358E-75");
08620: mathtest(147, def, "51542399.1", "-23212.2414", "51519186.9",
08621: "51565611.3", "-1.19641461E+12", "-2220.4835", "-2220",
08622: "11223.1920", "1.71641348E-179015");
08623: mathtest(148, def, "4.44287230", "158923023", "158923027",
08624: "-158923019", "706074697", "2.79561275E-8", "0",
08625: "4.44287230", "7.12573416E+102928693");
08626: mathtest(149, def, "-79123682.6", "-3.8571770", "-79123686.5",
08627: "-79123678.8", "305194049", "20513365.8", "20513365",
08628: "-2.9293950", "2.55137345E-32");
08629: mathtest(150, def, "-80.3324347E-569715030", "883142.351",
08630: "883142.351", "-883142.351", "-7.09449752E-569715023",
08631: "-9.09620455E-569715035", "0",
08632: "-8.03324347E-569715029", "");
08633: mathtest(151, def, "13637.483", "-52798.5631", "-39161.0801",
08634: "66436.0461", "-720039507", "-0.258292692", "0",
08635: "13637.483", "1.47163791E-218310");
08636: mathtest(152, def, "6.42934843E-276476458",
08637: "84057440.0E-388039782", "6.42934843E-276476458",
08638: "6.42934843E-276476458", "5.40434570E-664516232",
08639: "7.64875593E+111563316", "", "", "");
08640: mathtest(153, def, "-5.64133087", "-17401297.", "-17401302.6",
08641: "17401291.4", "98166473.9", "3.24190253E-7", "0",
08642: "-5.64133087", "-1.25908916E-13075014");
08643: mathtest(154, def, "95469.7057E+865733824", "198.829749",
08644: "9.54697057E+865733828", "9.54697057E+865733828",
08645: "1.89822176E+865733831", "4.80158056E+865733826", "",
08646: "", "");
08647: mathtest(155, def, "-416466.209", "-930153427", "-930569893",
08648: "929736961", "3.87377472E+14", "0.000447739262", "0",
08649: "-416466.209", "");
08650: mathtest(156, def, "-1541733.85", "-1.99208708", "-1541735.84",
08651: "-1541731.86", "3071268.08", "773928.944", "773928",
08652: "-1.88034976", "4.20708401E-13");
08653: mathtest(157, def, "-39152691.8", "-645131748.", "-684284440",
08654: "605979056", "2.52586445E+16", "0.0606894513", "0",
08655: "-39152691.8", "");
08656: mathtest(158, def, "113.939979", "-58282550.4", "-58282436.5",
08657: "58282664.3", "-6.64071257E+9", "-0.0000019549587",
08658: "0", "113.939979", "2.106557E-119868330");
08659: mathtest(159, def, "-324971.736", "-9517.15154", "-334488.888",
08660: "-315454.585", "3.09280526E+9", "34.1459033", "34",
08661: "-1388.58364", "-5.82795263E-52457");
08662: mathtest(160, def, "-76.9436744", "-9548122.75E-273599728",
08663: "-76.9436744", "-76.9436744", "7.34667648E-273599720",
08664: "8.05851332E+273599722", "", "", "1.37489895E-19");
08665: mathtest(161, def, "-430393.282", "-70.2551505", "-430463.537",
08666: "-430323.027", "30237344.8", "6126.14561", "6126",
08667: "-10.2300370", "4.26006409E-395");
08668: mathtest(162, def, "-3308051.90", "-349433799.E+397813188",
08669: "-3.49433799E+397813196", "3.49433799E+397813196",
08670: "1.15594514E+397813203", "9.46689161E-397813191", "0",
08671: "-3308051.90", "-2.76237768E-20");
08672: mathtest(163, def, "23.1543212E-655822712", "5848.20853",
08673: "5848.20853", "-5848.20853", "1.35411299E-655822707",
08674: "3.95921607E-655822715", "0", "2.31543212E-655822711",
08675: "");
08676: mathtest(164, def, "-174.261308E-82902077", "-200096204.",
08677: "-200096204", "200096204", "3.48690262E-82902067",
08678: "8.70887626E-82902084", "0", "-1.74261308E-82902075",
08679: "");
08680: mathtest(165, def, "-50669105.2", "9105789.01E+609889700",
08681: "9.10578901E+609889706", "-9.10578901E+609889706",
08682: "-4.61382181E+609889714", "-5.56449366E-609889700",
08683: "0", "-50669105.2", "-2.20135008E+69");
08684: mathtest(166, def, "424768856.", "-971.71757", "424767884",
08685: "424769828", "-4.12755361E+11", "-437132.012",
08686: "-437132", "11.19076", "2.72651473E-8387");
08687: mathtest(167, def, "7181.2767", "999117.918", "1006299.19",
08688: "-991936.641", "7.17494223E+9", "0.00718761677", "0",
08689: "7181.2767", "3.09655124E+3852800");
08690: mathtest(168, def, "8096417.07E-433694528", "-68.4863363",
08691: "-68.4863363", "68.4863363", "-5.54493942E-433694520",
08692: "-1.18219451E-433694523", "0", "8.09641707E-433694522",
08693: "");
08694: mathtest(169, def, "1236287.5", "-7119.97299E-176200498",
08695: "1236287.50", "1236287.50", "-8.80233361E-176200489",
08696: "-1.73636544E+176200500", "", "", "2.26549784E-43");
08697: mathtest(170, def, "-752995833E-654401067",
08698: "-15.2736930E+803939983", "-1.52736930E+803939984",
08699: "1.52736930E+803939984", "1.15010272E+149538926", "",
08700: "0", "-7.52995833E-654401059", "");
08701: mathtest(171, def, "702992.459", "-312.689474", "702679.770",
08702: "703305.148", "-219818342", "-2248.21274", "-2248",
08703: "66.521448", "8.02493322E-1831");
08704: mathtest(172, def, "-4414.38805", "-17680.4630E-584364536",
08705: "-4414.38805", "-4414.38805", "7.80484246E-584364529",
08706: "2.49676044E+584364535", "", "", "5.13167312E-8");
08707: mathtest(173, def, "9.46350807", "7826.65424", "7836.11775",
08708: "-7817.19073", "74067.6056", "0.00120913839", "0",
08709: "9.46350807", "3.63271495E+7639");
08710: mathtest(174, def, "2078153.7", "-16934607.3E+233594439",
08711: "-1.69346073E+233594446", "1.69346073E+233594446",
08712: "-3.51927168E+233594452", "-1.2271638E-233594440", "0",
08713: "2078153.7", "2.31549939E-13");
08714: mathtest(175, def, "-9359.74629", "7.07761788E+252457696",
08715: "7.07761788E+252457696", "-7.07761788E+252457696",
08716: "-6.62447077E+252457700", "-1.32244301E-252457693",
08717: "0", "-9359.74629", "-6.29286677E+27");
08718: mathtest(176, def, "66.2319284E+730468479",
08719: "25.9391685E+221147044", "6.62319284E+730468480",
08720: "6.62319284E+730468480", "1.71800115E+951615526",
08721: "2.55335588E+509321435", "", "", "");
08722: mathtest(177, def, "317997088.E-90968742", "-977426.461",
08723: "-977426.461", "977426.461", "-3.10818768E-90968728",
08724: "-3.2534119E-90968740", "0", "3.17997088E-90968734", "");
08725: mathtest(178, def, "227473386", "-6759.61390", "227466626",
08726: "227480146", "-1.53763226E+12", "-33651.8312",
08727: "-33651", "5618.65110", "1.40992627E-56493");
08728: mathtest(179, def, "-392019.462", "-245456.503", "-637475.965",
08729: "-146562.959", "9.62237263E+10", "1.59710359", "1",
08730: "-146562.959", "-3.08656533E-1372917");
08731: mathtest(180, def, "-3619556.28E+587673583", "-3.45236972",
08732: "-3.61955628E+587673589", "-3.61955628E+587673589",
08733: "1.24960465E+587673590", "1.04842661E+587673589", "",
08734: "", "");
08735: mathtest(181, def, "-249.400704E-923930848", "831102.919",
08736: "831102.919", "-831102.919", "-2.07277653E-923930840",
08737: "-3.00084019E-923930852", "0",
08738: "-2.49400704E-923930846", "");
08739: mathtest(182, def, "65234.2739E+154949914", "-694581895",
08740: "6.52342739E+154949918", "6.52342739E+154949918",
08741: "-4.53105456E+154949927", "-9.39187652E+154949909", "",
08742: "", "");
08743: mathtest(183, def, "45.2316213", "-88775083.4", "-88775038.2",
08744: "88775128.6", "-4.01544095E+9", "-5.09508069E-7", "0",
08745: "45.2316213", "1.92314254E-146962015");
08746: mathtest(184, def, "331100375.", "442.343378", "331100817",
08747: "331099933", "1.46460058E+11", "748514.37", "748514",
08748: "163.759708", "6.64011043E+3765");
08749: mathtest(185, def, "81.8162765", "5.61239515E+467372163",
08750: "5.61239515E+467372163", "-5.61239515E+467372163",
08751: "4.59185273E+467372165", "1.45777826E-467372162", "0",
08752: "81.8162765", "2.99942677E+11");
08753: mathtest(186, def, "-5738.13069E+789464078", "33969715.0",
08754: "-5.73813069E+789464081", "-5.73813069E+789464081",
08755: "-1.94922664E+789464089", "-1.68919012E+789464074", "",
08756: "", "");
08757: mathtest(187, def, "-7413.03911", "2.70630320E-254858264",
08758: "-7413.03911", "-7413.03911", "-2.00619315E-254858260",
08759: "-2.73917539E+254858267", "", "", "-4.07369842E+11");
08760: mathtest(188, def, "-417696.182", "27400.6002", "-390295.582",
08761: "-445096.782", "-1.14451261E+10", "-15.2440523", "-15",
08762: "-6687.1790", "-1.58020334E+154017");
08763: mathtest(189, def, "68.8538735E+655647287",
08764: "3198.17933E-132454826", "6.88538735E+655647288",
08765: "6.88538735E+655647288", "2.20207035E+523192466",
08766: "2.15290846E+788102111", "", "", "");
08767: mathtest(190, def, "-6817.04246", "434420.439", "427603.397",
08768: "-441237.481", "-2.96146258E+9", "-0.0156922692", "0",
08769: "-6817.04246", "5.94143518E+1665390");
08770: mathtest(191, def, "8578.27511", "647042.341E-490924334",
08771: "8578.27511", "8578.27511", "5.55050721E-490924325",
08772: "1.3257672E+490924332", "", "", "3.98473846E+23");
08773: mathtest(192, def, "4124.11615E+733109424",
08774: "597385828E+375928745", "4.12411615E+733109427",
08775: "4.12411615E+733109427", "", "6.9036056E+357180673",
08776: "", "", "");
08777: mathtest(193, def, "102.714400", "-919017.468", "-918914.754",
08778: "919120.182", "-94396327.8", "-0.000111765449", "0",
08779: "102.714400", "4.04295689E-1848724");
08780: mathtest(194, def, "-4614.33015E+996778733",
08781: "-433.560812E+22860599", "-4.61433015E+996778736",
08782: "-4.61433015E+996778736", "", "1.06428672E+973918135",
08783: "", "", "");
08784: mathtest(195, def, "457455170.", "3709230.48E+677010879",
08785: "3.70923048E+677010885", "-3.70923048E+677010885",
08786: "1.69680666E+677010894", "1.23328861E-677010877", "0",
08787: "457455170", "4.37919376E+34");
08788: mathtest(196, def, "-2522468.15", "-48482043.5", "-51004511.7",
08789: "45959575.4", "1.22294411E+14", "0.0520289156", "0",
08790: "-2522468.15", "1.42348178E-310373595");
08791: mathtest(197, def, "-659811384", "62777.6118", "-659748606",
08792: "-659874162", "-4.14213829E+13", "-10510.2976",
08793: "-10510", "-18683.9820", "3.4393524E+553665");
08794: mathtest(198, def, "4424.94176", "-825848.20", "-821423.258",
08795: "830273.142", "-3.65433019E+9", "-0.00535805704", "0",
08796: "4424.94176", "3.42152775E-3010966");
08797: mathtest(199, def, "43.6441884", "-6509.89663E-614169377",
08798: "43.6441884", "43.6441884", "-2.84119155E-614169372",
08799: "-6.70428286E+614169374", "", "", "3.31524056E-12");
08800: mathtest(200, def, "897.388381E-843864876", "84195.1369",
08801: "84195.1369", "-84195.1369", "7.55557376E-843864869",
08802: "1.06584348E-843864878", "0", "8.97388381E-843864874",
08803: "");
08804: mathtest(201, def, "796199825", "496.76834", "796200322",
08805: "796199328", "3.95526865E+11", "1602758.79", "1602758",
08806: "393.91828", "6.42647264E+4423");
08807: mathtest(202, def, "573583582", "1598.69521", "573585181",
08808: "573581983", "9.16985325E+11", "358782.323", "358782",
08809: "517.16578", "9.91156302E+14004");
08810: mathtest(203, def, "-783144270.", "6347.71496", "-783137922",
08811: "-783150618", "-4.97117660E+12", "-123374.202",
08812: "-123374", "-1284.52496", "1.28110803E+56458");
08813: mathtest(204, def, "26909234.7", "52411.5081", "26961646.2",
08814: "26856823.2", "1.41035357E+12", "513.422255", "513",
08815: "22131.0447", "9.75836528E+389415");
08816: mathtest(205, def, "8.21915282", "24859.7841E-843282959",
08817: "8.21915282", "8.21915282", "2.04326365E-843282954",
08818: "3.30620443E+843282955", "", "", "67.5544731");
08819: mathtest(206, def, "-688.387710", "82783.5207E-831870858",
08820: "-688.387710", "-688.387710", "-5.69871582E-831870851",
08821: "-8.31551623E+831870855", "", "", "5.04272012E+22");
08822: mathtest(207, def, "-9792232.", "-1749.01166", "-9793981.01",
08823: "-9790482.99", "1.71267279E+10", "5598.72311", "5598",
08824: "-1264.72732", "-8.86985674E-12228");
08825: mathtest(208, def, "-130.765600", "8.67437427", "-122.091226",
08826: "-139.439974", "-1134.30976", "-15.0749317", "-15",
08827: "-0.64998595", "-1.11799947E+19");
08828: mathtest(209, def, "917.259102", "-368640.426", "-367723.167",
08829: "369557.685", "-338138786", "-0.00248822169", "0",
08830: "917.259102", "8.67104255E-1092094");
08831: mathtest(210, def, "-4.9725631", "-294563717.", "-294563722",
08832: "294563712", "1.46473667E+9", "1.6881112E-8", "0",
08833: "-4.9725631", "-6.27962584E-205187284");
08834: mathtest(211, def, "-60962887.2E-514249661", "-243021.407",
08835: "-243021.407", "243021.407", "1.48152866E-514249648",
08836: "2.5085398E-514249659", "0", "-6.09628872E-514249654",
08837: "");
08838: mathtest(212, def, "-55389219.8", "-3772200E+981866393",
08839: "-3.77220000E+981866399", "3.77220000E+981866399",
08840: "2.08939215E+981866407", "1.46835321E-981866392", "0",
08841: "-55389219.8", "1.06242678E-31");
08842: mathtest(213, def, "681.666010", "626886700", "626887382",
08843: "-626886018", "4.27327356E+11", "0.00000108738311",
08844: "0", "681.666010", "");
08845: mathtest(214, def, "6.42652138", "53465894.5", "53465900.9",
08846: "-53465888.1", "343599714", "1.2019852E-7", "0",
08847: "6.42652138", "4.61155532E+43199157");
08848: mathtest(215, def, "561546656", "651408.476", "562198064",
08849: "560895248", "3.65796251E+14", "862.049968", "862",
08850: "32549.688", "8.6052377E+5699419");
08851: mathtest(216, def, "7845778.36E-79951139", "9.45859047",
08852: "9.45859047", "-9.45859047", "7.42100044E-79951132",
08853: "8.29487056E-79951134", "0", "7.84577836E-79951133",
08854: "1.12648216E-719560189");
08855: mathtest(217, def, "54486.2112", "10.7565078", "54496.9677",
08856: "54475.4547", "586081.356", "5065.41828", "5065",
08857: "4.4991930", "1.25647168E+52");
08858: mathtest(218, def, "16576482.5", "-2217720.83", "14358761.7",
08859: "18794203.3", "-3.67620105E+13", "-7.47455779", "-7",
08860: "1052436.69", "1.38259374E-16010820");
08861: mathtest(219, def, "61.2793787E-392070111", "6.22575651",
08862: "6.22575651", "-6.22575651", "3.81510491E-392070109",
08863: "9.84288072E-392070111", "0", "6.12793787E-392070110",
08864: "");
08865: mathtest(220, def, "5115136.39", "-653674372.", "-648559236",
08866: "658789508", "-3.34363357E+15", "-0.00782520565", "0",
08867: "5115136.39", "");
08868: mathtest(221, def, "-7.84238366E-416477339",
08869: "-37432758.9E+97369393", "-3.74327589E+97369400",
08870: "3.74327589E+97369400", "2.93562057E-319107938",
08871: "2.09505895E-513846739", "0", "-7.84238366E-416477339",
08872: "");
08873: mathtest(222, def, "-387781.3E+284108380", "-218085.592",
08874: "-3.87781300E+284108385", "-3.87781300E+284108385",
08875: "8.45695144E+284108390", "1.77811517E+284108380", "",
08876: "", "");
08877: mathtest(223, def, "-5353.17736", "3.39332346E+546685359",
08878: "3.39332346E+546685359", "-3.39332346E+546685359",
08879: "-1.81650623E+546685363", "-1.57756177E-546685356",
08880: "0", "-5353.17736", "-1.53403369E+11");
08881: mathtest(224, def, "-20837.2900E-168652772",
08882: "-8236.78305E-712819173", "-2.08372900E-168652768",
08883: "-2.08372900E-168652768", "1.71632237E-881471937",
08884: "2.52978497E+544166401", "", "", "");
08885: mathtest(225, def, "-98573.8722E+829022366", "309011.007",
08886: "-9.85738722E+829022370", "-9.85738722E+829022370",
08887: "-3.04604115E+829022376", "-3.18997932E+829022365", "",
08888: "", "");
08889: mathtest(226, def, "49730750.7", "-5315.10636E-299586991",
08890: "49730750.7", "49730750.7", "-2.64324229E-299586980",
08891: "-9.35649211E+299586994", "", "", "3.28756936E-39");
08892: mathtest(227, def, "1539523.40", "-962388.581", "577134.82",
08893: "2501911.98", "-1.48161974E+12", "-1.59969001", "-1",
08894: "577134.819", "3.10144834E-5954673");
08895: mathtest(228, def, "81596.2121", "-37600.9653", "43995.2468",
08896: "119197.177", "-3.06809634E+9", "-2.17005631", "-2",
08897: "6394.2815", "1.97878299E-184684");
08898: mathtest(229, def, "590146199", "-1425404.61", "588720794",
08899: "591571604", "-8.41197113E+14", "-414.020128", "-414",
08900: "28690.46", "2.04650994E-12502170");
08901: mathtest(230, def, "196.05543", "505.936305", "701.991735",
08902: "-309.880875", "99191.5598", "0.387510104", "0",
08903: "196.05543", "8.78437397E+1159");
08904: mathtest(231, def, "77.8058449", "-642.275274", "-564.469429",
08905: "720.081119", "-49972.7704", "-0.121140963", "0",
08906: "77.8058449", "9.33582626E-1215");
08907: mathtest(232, def, "1468.60684", "10068.138", "11536.7448",
08908: "-8599.5312", "14786136.3", "0.145866777", "0",
08909: "1468.60684", "2.54122484E+31884");
08910: mathtest(233, def, "4.98774767E-387968632",
08911: "4.41731439E-578812376", "4.98774767E-387968632",
08912: "4.98774767E-387968632", "2.20324496E-966781007",
08913: "1.12913577E+190843744", "", "", "");
08914: mathtest(234, def, "981.091059", "-92238.9930", "-91257.9020",
08915: "93220.0841", "-90494851.3", "-0.0106364025", "0",
08916: "981.091059", "5.29943342E-275953");
08917: mathtest(235, def, "-3606.24992", "8290224.70", "8286618.45",
08918: "-8293830.95", "-2.98966222E+10", "-0.000435000262",
08919: "0", "-3606.24992", "-1.23747107E+29488793");
08920: mathtest(236, def, "-8978571.35", "92243.4796", "-8886327.87",
08921: "-9070814.83", "-8.28214663E+11", "-97.3355666", "-97",
08922: "-30953.8288", "-4.95762813E+641384");
08923: mathtest(237, def, "-61968.1992E+810060478",
08924: "474294671.E+179263414", "-6.19681992E+810060482",
08925: "-6.19681992E+810060482", "-2.93911867E+989323905",
08926: "-1.30653374E+630797060", "", "", "");
08927: mathtest(238, def, "61298431.6E-754429041", "-2584862.79",
08928: "-2584862.79", "2584862.79", "-1.58448035E-754429027",
08929: "-2.37143851E-754429040", "0", "6.12984316E-754429034",
08930: "");
08931: mathtest(239, def, "621039.064", "-5351539.62", "-4730500.56",
08932: "5972578.68", "-3.32351516E+12", "-0.116048672", "0",
08933: "621039.064", "2.41163312E-31002108");
08934: mathtest(240, def, "-19.6007605", "-57905696.", "-57905715.6",
08935: "57905676.4", "1.13499568E+9", "3.38494515E-7", "0",
08936: "-19.6007605", "1.05663646E-74829963");
08937: mathtest(241, def, "3626.13109E+687030346", "189.896004",
08938: "3.62613109E+687030349", "3.62613109E+687030349",
08939: "6.88587804E+687030351", "1.90953523E+687030347", "",
08940: "", "");
08941: mathtest(242, def, "-249334.026", "-7.54735834E-14137188",
08942: "-249334.026", "-249334.026", "1.88181324E-14137182",
08943: "3.30359332E+14137192", "", "", "6.69495408E-44");
08944: mathtest(243, def, "417613928.", "-925213.216", "416688715",
08945: "418539141", "-3.86381925E+14", "-451.370474", "-451",
08946: "342767.584", "8.38430085E-7976054");
08947: mathtest(244, def, "23.8320309", "-50074996.1", "-50074972.3",
08948: "50075019.9", "-1.19338885E+9", "-4.75926765E-7", "0",
08949: "23.8320309", "5.81466387E-68961335");
08950: mathtest(245, def, "49789677.7", "-131827812E+156412534",
08951: "-1.31827812E+156412542", "1.31827812E+156412542",
08952: "-6.56366427E+156412549", "-3.77687204E-156412535",
08953: "0", "49789677.7", "2.00844843E-8");
08954: mathtest(246, def, "-8907163.61E-741867246",
08955: "773651.288E-472033282", "7.73651288E-472033277",
08956: "-7.73651288E-472033277", "", "-1.15131504E-269833963",
08957: "0", "-8.90716361E-741867240", "");
08958: mathtest(247, def, "514021711.E+463536646", "617441659.",
08959: "5.14021711E+463536654", "5.14021711E+463536654",
08960: "3.17378418E+463536663", "8.32502478E+463536645", "",
08961: "", "");
08962: mathtest(248, def, "998175750", "2.39285478", "998175752",
08963: "998175748", "2.38848961E+9", "417148487", "417148486",
08964: "1.30513692", "9.96354828E+17");
08965: mathtest(249, def, "873575426.", "647853.152E+497450781",
08966: "6.47853152E+497450786", "-6.47853152E+497450786",
08967: "5.65948593E+497450795", "1.3484158E-497450778", "0",
08968: "873575426", "4.44429064E+53");
08969: mathtest(250, def, "4352626.8", "-130338048.E-744560911",
08970: "4352626.80", "4352626.80", "-5.67312881E-744560897",
08971: "-3.33949055E+744560909", "", "", "2.29746322E-7");
08972: mathtest(251, def, "437.286960", "7.37560835", "444.662568",
08973: "429.911352", "3225.25735", "59.2882565", "59",
08974: "2.12606735", "3.05749452E+18");
08975: mathtest(252, def, "8498280.45E+220511522", "588617612",
08976: "8.49828045E+220511528", "8.49828045E+220511528",
08977: "5.00223754E+220511537", "1.44376931E+220511520", "",
08978: "", "");
08979: mathtest(253, def, "-5320387.77", "-7673237.46", "-12993625.2",
08980: "2352849.69", "4.08245987E+13", "0.693369363", "0",
08981: "-5320387.77", "-1.30113745E-51609757");
08982: mathtest(254, def, "587655375", "-4.9748366", "587655370",
08983: "587655380", "-2.92348947E+9", "-118125563",
08984: "-118125563", "0.7919942", "1.42687667E-44");
08985: mathtest(255, def, "1266098.44", "-2661.64904E-642601142",
08986: "1266098.44", "1266098.44", "-3.36990970E-642601133",
08987: "-4.75681963E+642601144", "", "", "4.92717036E-19");
08988: mathtest(256, def, "3.92737463E+482873483", "-685.522747",
08989: "3.92737463E+482873483", "3.92737463E+482873483",
08990: "-2.69230464E+482873486", "-5.72902161E+482873480", "",
08991: "", "");
08992: mathtest(257, def, "22826494.1", "986189474.", "1.00901597E+9",
08993: "-963362980", "2.25112482E+16", "0.0231461547", "0",
08994: "22826494.1", "");
08995: mathtest(258, def, "-647342.380", "-498816386", "-499463728",
08996: "498169044", "3.22904986E+14", "0.00129775685", "0",
08997: "-647342.380", "");
08998: mathtest(259, def, "393092373.", "-25.7226822", "393092347",
08999: "393092399", "-1.01113902E+10", "-15281935.6",
09000: "-15281935", "15.5939430", "3.49252839E-224");
09001: mathtest(260, def, "2.96253492", "20.7444888", "23.7070237",
09002: "-17.7819539", "61.4562725", "0.142810698", "0",
09003: "2.96253492", "8.03402246E+9");
09004: mathtest(261, def, "53553.3750E+386955423", "-732470876",
09005: "5.35533750E+386955427", "5.35533750E+386955427",
09006: "-3.92262875E+386955436", "-7.31133165E+386955418", "",
09007: "", "");
09008: mathtest(262, def, "-696451.406E-286535917", "-73086090.8",
09009: "-73086090.8", "73086090.8", "5.09009107E-286535904",
09010: "9.52919219E-286535920", "0", "-6.96451406E-286535912",
09011: "");
09012: mathtest(263, def, "1551.29957", "-580358622.E+117017265",
09013: "-5.80358622E+117017273", "5.80358622E+117017273",
09014: "-9.00310081E+117017276", "-2.67300168E-117017271",
09015: "0", "1551.29957", "7.17506711E-20");
09016: mathtest(264, def, "-205123006.E-213752799", "-78638468.6",
09017: "-78638468.6", "78638468.6", "1.61305591E-213752783",
09018: "2.60843083E-213752799", "0", "-2.05123006E-213752791",
09019: "");
09020: mathtest(265, def, "77632.8073", "-3378542.88E+677441319",
09021: "-3.37854288E+677441325", "3.37854288E+677441325",
09022: "-2.62285768E+677441330", "-2.29781921E-677441321",
09023: "0", "77632.8073", "2.13729331E-15");
09024: mathtest(266, def, "3068999.37", "2.21006212", "3069001.58",
09025: "3068997.16", "6782679.25", "1388648.46", "1388648",
09026: "1.02718624", "9.41875713E+12");
09027: mathtest(267, def, "625524274.", "55.2468624", "625524329",
09028: "625524219", "3.45582535E+10", "11322349.3",
09029: "11322349", "16.7522224", "6.21482943E+483");
09030: mathtest(268, def, "61269134.9", "-845761303.", "-784492168",
09031: "907030438", "-5.18190634E+16", "-0.0724425848", "0",
09032: "61269134.9", "");
09033: mathtest(269, def, "-2840.12099", "-2856.76731E-82743650",
09034: "-2840.12099", "-2840.12099", "8.11356480E-82743644",
09035: "9.94173022E+82743649", "", "", "-4.36505254E-11");
09036: mathtest(270, def, "8.9538781", "-7.56603391", "1.38784419",
09037: "16.5199120", "-67.7453453", "-1.18343087", "-1",
09038: "1.38784419", "2.42053061E-8");
09039: mathtest(271, def, "-56233547.2", "509752530", "453518983",
09040: "-565986077", "-2.86651930E+16", "-0.110315386", "0",
09041: "-56233547.2", "");
09042: mathtest(272, def, "-3167.47853E-854859497", "-110852115",
09043: "-110852115", "110852115", "3.51121694E-854859486",
09044: "2.85739116E-854859502", "0", "-3.16747853E-854859494",
09045: "");
09046: mathtest(273, def, "-5652.52092", "-632243244.", "-632248897",
09047: "632237592", "3.57376816E+12", "0.00000894042123", "0",
09048: "-5652.52092", "");
09049: mathtest(274, def, "-946.009928", "820090.66E-589278015",
09050: "-946.009928", "-946.009928", "-7.75813906E-589278007",
09051: "-1.15354311E+589278012", "", "", "6.41454053E+23");
09052: mathtest(275, def, "-367.757758", "-959.626016", "-1327.38377",
09053: "591.868258", "352909.912", "0.383230292", "0",
09054: "-367.757758", "1.14982199E-2463");
09055: mathtest(276, def, "809926721.E-744611554", "-67.6560549",
09056: "-67.6560549", "67.6560549", "-5.47964467E-744611544",
09057: "-1.19712378E-744611547", "0", "8.09926721E-744611546",
09058: "");
09059: mathtest(277, def, "-1725.08555", "75586.3031", "73861.2176",
09060: "-77311.3887", "-130392839", "-0.0228227269", "0",
09061: "-1725.08555", "3.70540587E+244657");
09062: mathtest(278, def, "2659.84191E+29314492",
09063: "-74372.4551E+518196680", "-7.43724551E+518196684",
09064: "7.43724551E+518196684", "-1.97818973E+547511180",
09065: "-3.5763804E-488882190", "0", "2.65984191E+29314495",
09066: "1.06171811E-205201468");
09067: mathtest(279, def, "-91.1431113", "12147507.0", "12147415.9",
09068: "-12147598.1", "-1.10716158E+9", "-0.00000750303015",
09069: "0", "-91.1431113", "-1.52417006E+23805759");
09070: mathtest(280, def, "-1136778.91E+697783878", "-801552569.",
09071: "-1.13677891E+697783884", "-1.13677891E+697783884",
09072: "9.11188056E+697783892", "1.41822128E+697783875", "",
09073: "", "");
09074: mathtest(281, def, "73123773.0E+433334149", "63.3548930",
09075: "7.31237730E+433334156", "7.31237730E+433334156",
09076: "4.63274881E+433334158", "1.15419298E+433334155", "",
09077: "", "");
09078: mathtest(282, def, "-9765484.8", "7979.90802E-234029715",
09079: "-9765484.80", "-9765484.80", "-7.79276705E-234029705",
09080: "-1.22375907E+234029718", "", "", "8.27085614E+55");
09081: mathtest(283, def, "-695010288", "-8.26582820", "-695010296",
09082: "-695010280", "5.74483564E+9", "84082353.4",
09083: "84082353", "-3.45024540", "1.83683495E-71");
09084: mathtest(284, def, "23975643.3E-155955264",
09085: "-505547.692E+137258948", "-5.05547692E+137258953",
09086: "5.05547692E+137258953", "-1.21208311E-18696303",
09087: "-4.7425087E-293214211", "0", "2.39756433E-155955257",
09088: "1.26225952E+779776283");
09089: mathtest(285, def, "2862.95921", "-32601248.6E-605861333",
09090: "2862.95921", "2862.95921", "-9.33360449E-605861323",
09091: "-8.78174712E+605861328", "", "", "4.26142175E-11");
09092: mathtest(286, def, "-13.133518E+246090516",
09093: "-8.71269925E-945092108", "-1.31335180E+246090517",
09094: "-1.31335180E+246090517", "1.14428392E-699001590", "",
09095: "", "", "");
09096: mathtest(287, def, "-34671.2232", "817710.762", "783039.539",
09097: "-852381.985", "-2.83510323E+10", "-0.0424003508", "0",
09098: "-34671.2232", "-5.30788828E+3712382");
09099: mathtest(288, def, "-22464769", "62.4366060", "-22464706.6",
09100: "-22464831.4", "-1.40262393E+9", "-359801.252",
09101: "-359801", "-15.7245940", "6.21042536E+455");
09102: mathtest(289, def, "-9458.60887E-563051963", "5676056.01",
09103: "5676056.01", "-5676056.01", "-5.36875937E-563051953",
09104: "-1.66640513E-563051966", "0",
09105: "-9.45860887E-563051960", "");
09106: mathtest(290, def, "-591.924123E-95331874", "-134.596188",
09107: "-134.596188", "134.596188", "7.96707305E-95331870",
09108: "4.39777777E-95331874", "0", "-5.91924123E-95331872",
09109: "");
09110: mathtest(291, def, "-182566085.E+68870646", "-960345993.",
09111: "-1.82566085E+68870654", "-1.82566085E+68870654",
09112: "1.75326608E+68870663", "1.9010449E+68870645", "", "",
09113: "");
09114: mathtest(292, def, "8232.54893", "-99822004E+891979845",
09115: "-9.98220040E+891979852", "9.98220040E+891979852",
09116: "-8.21789532E+891979856", "-8.24722867E-891979850",
09117: "0", "8232.54893", "6.99289156E-40");
09118: mathtest(293, def, "-4336.94317", "-819373.601E+563233430",
09119: "-8.19373601E+563233435", "8.19373601E+563233435",
09120: "3.55357674E+563233439", "5.29299841E-563233433", "0",
09121: "-4336.94317", "7.98969405E-30");
09122: mathtest(294, def, "-2.09044362E-876527908", "-6515463.33",
09123: "-6515463.33", "6515463.33", "1.36202087E-876527901",
09124: "3.20843433E-876527915", "0", "-2.09044362E-876527908",
09125: "");
09126: mathtest(295, def, "-194343.344", "1.95929977", "-194341.385",
09127: "-194345.303", "-380776.869", "-99190.2041", "-99190",
09128: "-0.39981370", "3.77693354E+10");
09129: mathtest(296, def, "-326002.927", "4215.99030", "-321786.937",
09130: "-330218.917", "-1.37442518E+9", "-77.3253503", "-77",
09131: "-1371.67390", "5.51875821E+23243");
09132: mathtest(297, def, "-12037.8590E+876429044", "314.81827",
09133: "-1.20378590E+876429048", "-1.20378590E+876429048",
09134: "-3.78973794E+876429050", "-3.82374854E+876429045", "",
09135: "", "");
09136: mathtest(298, def, "21036045.4E-162804809", "-91.7149219",
09137: "-91.7149219", "91.7149219", "-1.92931926E-162804800",
09138: "-2.2936339E-162804804", "0", "2.10360454E-162804802",
09139: "");
09140: mathtest(299, def, "-947019.534", "9916.29280", "-937103.241",
09141: "-956935.827", "-9.39092299E+9", "-95.5013686", "-95",
09142: "-4971.71800", "3.76029022E+59261");
09143: mathtest(300, def, "-5985.84136", "-12.4090184E-12364204",
09144: "-5985.84136", "-5985.84136", "7.42784156E-12364200",
09145: "4.82378313E+12364206", "", "", "-0.000167060893");
09146: mathtest(301, def, "-85344379.4", "-6783.08669E+218840215",
09147: "-6.78308669E+218840218", "6.78308669E+218840218",
09148: "5.78898324E+218840226", "1.25819385E-218840211", "0",
09149: "-85344379.4", "-3.03232347E-56");
09150: mathtest(302, def, "-94.1947070E-938257103", "15003.240",
09151: "15003.2400", "-15003.2400", "-1.41322580E-938257097",
09152: "-6.27829102E-938257106", "0",
09153: "-9.41947070E-938257102", "");
09154: mathtest(303, def, "-4846233.6", "-8289769.76", "-13136003.4",
09155: "3443536.16", "4.01741607E+13", "0.584604125", "0",
09156: "-4846233.6", "4.25077524E-55420465");
09157: mathtest(304, def, "67.9147198", "-108373645.E+291715415",
09158: "-1.08373645E+291715423", "1.08373645E+291715423",
09159: "-7.36016573E+291715424", "-6.26671916E-291715422",
09160: "0", "67.9147198", "0.0147243485");
09161: mathtest(305, def, "1958.77994", "5.57285137E+690137826",
09162: "5.57285137E+690137826", "-5.57285137E+690137826",
09163: "1.09159895E+690137830", "3.51486126E-690137824", "0",
09164: "1958.77994", "5.64824968E+19");
09165: mathtest(306, def, "22780314.3", "8805279.83", "31585594.1",
09166: "13975034.5", "2.00587042E+14", "2.58711986", "2",
09167: "5169754.64", "2.39132169E+64785373");
09168: mathtest(307, def, "596745.184", "197602423.", "198199168",
09169: "-197005678", "1.17918294E+14", "0.00301992848", "0",
09170: "596745.184", "");
09171: mathtest(308, def, "171.340497", "-480349.924", "-480178.584",
09172: "480521.264", "-82303394.7", "-0.000356699332", "0",
09173: "171.340497", "2.17914102E-1073035");
09174: mathtest(309, def, "824.65555", "-379287.530", "-378462.875",
09175: "380112.186", "-312781567", "-0.00217422268", "0",
09176: "824.65555", "6.35829256E-1106108");
09177: mathtest(310, def, "19.3164031", "-9207644.24E+988115069",
09178: "-9.20764424E+988115075", "9.20764424E+988115075",
09179: "-1.77858568E+988115077", "-2.09786592E-988115075",
09180: "0", "19.3164031", "2.67093711E-12");
09181: mathtest(311, def, "-3123.77646E+177814265",
09182: "973284435.E+383256112", "9.73284435E+383256120",
09183: "-9.73284435E+383256120", "-3.04032301E+561070389",
09184: "-3.20952062E-205441853", "0",
09185: "-3.12377646E+177814268", "");
09186: mathtest(312, def, "-850.123915E+662955309",
09187: "6774849.81E-846576865", "-8.50123915E+662955311",
09188: "-8.50123915E+662955311", "-5.75946184E-183621547", "",
09189: "", "", "");
09190: mathtest(313, def, "-23349.7724", "2921.35355", "-20428.4189",
09191: "-26271.1260", "-68212940.5", "-7.99279238", "-7",
09192: "-2900.29755", "-5.6705546E+12759");
09193: mathtest(314, def, "18886653.3", "568707476.", "587594129",
09194: "-549820823", "1.07409809E+16", "0.0332097855", "0",
09195: "18886653.3", "");
09196: mathtest(315, def, "-90552818.0", "-542.03563E-986606878",
09197: "-90552818.0", "-90552818.0", "4.90828538E-986606868",
09198: "1.67060638E+986606883", "", "", "-1.64244241E-40");
09199: mathtest(316, def, "41501126.1E+791838765",
09200: "-69.6651675E+204268348", "4.15011261E+791838772",
09201: "4.15011261E+791838772", "-2.89118290E+996107122",
09202: "-5.95722763E+587570422", "", "", "");
09203: mathtest(317, def, "76783193.3E-271488154",
09204: "3765.01829E-520346003", "7.67831933E-271488147",
09205: "7.67831933E-271488147", "2.89090127E-791834146",
09206: "2.03938434E+248857853", "", "", "");
09207: mathtest(318, def, "4192.9928", "987822007E-146560989",
09208: "4192.99280", "4192.99280", "4.14193056E-146560977",
09209: "4.24468454E+146560983", "", "", "1.67973653E+36");
09210: mathtest(319, def, "-891845.629", "48277955.", "47386109.4",
09211: "-49169800.6", "-4.30564831E+13", "-0.0184731443", "0",
09212: "-891845.629", "-6.32964147E+287267817");
09213: mathtest(320, def, "334.901176", "-7609296.55E+447340228",
09214: "-7.60929655E+447340234", "7.60929655E+447340234",
09215: "-2.54836236E+447340237", "-4.40121073E-447340233",
09216: "0", "334.901176", "6.31926575E-21");
09217: mathtest(321, def, "4.49868636", "-341880896E-447251873",
09218: "4.49868636", "4.49868636", "-1.53801492E-447251864",
09219: "-1.31586363E+447251865", "", "", "0.010983553");
09220: mathtest(322, def, "807615.58", "-314286480", "-313478865",
09221: "315094096", "-2.53822658E+14", "-0.00256967968", "0",
09222: "807615.58", "");
09223: mathtest(323, def, "-37.7457954", "53277.8129E-859225538",
09224: "-37.7457954", "-37.7457954", "-2.01101343E-859225532",
09225: "-7.08471188E+859225534", "", "", "-76620134.1");
09226: mathtest(324, def, "-28671081.", "98.8819623", "-28670982.1",
09227: "-28671179.9", "-2.83505275E+9", "-289952.589",
09228: "-289952", "-58.2671904", "-1.93625566E+738");
09229: mathtest(325, def, "-89752.2106E-469496896", "99.9879961",
09230: "99.9879961", "-99.9879961", "-8.97414368E-469496890",
09231: "-8.97629857E-469496894", "0",
09232: "-8.97522106E-469496892", "");
09233: mathtest(326, def, "-497983567E-13538052", "39.4578742",
09234: "39.4578742", "-39.4578742", "-1.96493729E-13538042",
09235: "-1.26206385E-13538045", "0", "-4.97983567E-13538044",
09236: "-1.55376543E-527983689");
09237: mathtest(327, def, "845739221E-654202565", "-33313.1551",
09238: "-33313.1551", "33313.1551", "-2.81742418E-654202552",
09239: "-2.53875449E-654202561", "0", "8.45739221E-654202557",
09240: "");
09241: mathtest(328, def, "742.332067E+537827843",
09242: "-4532.70023E-855387414", "7.42332067E+537827845",
09243: "7.42332067E+537827845", "-3.36476873E-317559565", "",
09244: "", "", "");
09245: mathtest(329, def, "-893.48654", "670389960", "670389067",
09246: "-670390853", "-5.98984406E+11", "-0.00000133278628",
09247: "0", "-893.48654", "");
09248: mathtest(330, def, "1.37697162", "-915.737474E-351578724",
09249: "1.37697162", "1.37697162", "-1.26094451E-351578721",
09250: "-1.50367508E+351578721", "", "", "0.0561920784");
09251: mathtest(331, def, "-65.2839808E+550288403", "-121389.306",
09252: "-6.52839808E+550288404", "-6.52839808E+550288404",
09253: "7.92477712E+550288409", "5.37806689E+550288399", "",
09254: "", "");
09255: mathtest(332, def, "-30346603.E+346067390", "792661.544",
09256: "-3.03466030E+346067397", "-3.03466030E+346067397",
09257: "-2.40545852E+346067403", "-3.82844396E+346067391", "",
09258: "", "");
09259: mathtest(333, def, "-61170.7065", "-453731131.", "-453792302",
09260: "453669960", "2.77550538E+13", "0.000134817081", "0",
09261: "-61170.7065", "");
09262: mathtest(334, def, "6569.51133", "13.8706351E+399434914",
09263: "1.38706351E+399434915", "-1.38706351E+399434915",
09264: "9.11232944E+399434918", "4.73627291E-399434912", "0",
09265: "6569.51133", "6569.51133");
09266: mathtest(335, def, "300703925.", "-3156736.8", "297547188",
09267: "303860662", "-9.49243146E+14", "-95.2578387", "-95",
09268: "813929.0", "4.18609114E-26763256");
09269: mathtest(336, def, "192138216E+353011592", "-473.080633",
09270: "1.92138216E+353011600", "1.92138216E+353011600",
09271: "-9.08968688E+353011602", "-4.06142637E+353011597", "",
09272: "", "");
09273: mathtest(337, def, "8607.64794", "-34740.3367", "-26132.6888",
09274: "43347.9846", "-299032588", "-0.247770999", "0",
09275: "8607.64794", "1.29604519E-136698");
09276: mathtest(338, def, "-67913.8241", "-93815.4229", "-161729.247",
09277: "25901.5988", "6.37136413E+9", "0.723908948", "0",
09278: "-67913.8241", "-6.96355203E-453311");
09279: mathtest(339, def, "34.5559455", "-998799398.", "-998799364",
09280: "998799433", "-3.45144576E+10", "-3.45974833E-8", "0",
09281: "34.5559455", "");
09282: mathtest(340, def, "387995.328", "990199543.E-124623607",
09283: "387995.328", "387995.328", "3.84192796E-124623593",
09284: "3.91835495E+124623603", "", "", "7.73152138E+55");
09285: mathtest(341, def, "-471.09166E-83521919", "-441222368",
09286: "-441222368", "441222368", "2.07856178E-83521908",
09287: "1.06769669E-83521925", "0", "-4.7109166E-83521917", "");
09288: mathtest(342, def, "-97834.3858", "70779789.8E+502166065",
09289: "7.07797898E+502166072", "-7.07797898E+502166072",
09290: "-6.92469726E+502166077", "-1.38223617E-502166068",
09291: "0", "-97834.3858", "-8.57907886E+34");
09292: mathtest(343, def, "7732331.06", "-952719.482E+115325505",
09293: "-9.52719482E+115325510", "9.52719482E+115325510",
09294: "-7.36674244E+115325517", "-8.11606271E-115325505",
09295: "0", "7732331.06", "1.30886724E-69");
09296: mathtest(344, def, "23.2745547", "2.23194245E-221062592",
09297: "23.2745547", "23.2745547", "5.19474666E-221062591",
09298: "1.04279368E+221062593", "", "", "541.704896");
09299: mathtest(345, def, "671.083363E-218324205", "-787150031",
09300: "-787150031", "787150031", "-5.28243290E-218324194",
09301: "-8.52548227E-218324212", "0", "6.71083363E-218324203",
09302: "");
09303: mathtest(346, def, "365167.80", "-80263.6516", "284904.148",
09304: "445431.452", "-2.93097011E+10", "-4.54960362", "-4",
09305: "44113.1936", "1.27052227E-446468");
09306: mathtest(347, def, "-1.43297604E-65129780",
09307: "56.598733E-135581942", "-1.43297604E-65129780",
09308: "-1.43297604E-65129780", "-8.11046283E-200711721",
09309: "-2.53181646E+70452160", "", "",
09310: "8.65831881E-390778680");
09311: mathtest(348, def, "416998859.", "260.220323E-349285593",
09312: "416998859", "416998859", "1.08511578E-349285582",
09313: "1.60248383E+349285599", "", "", "7.25111178E+25");
09314: mathtest(349, def, "7267.17611E+862630607", "4021.56861",
09315: "7.26717611E+862630610", "7.26717611E+862630610",
09316: "2.92254473E+862630614", "1.80705014E+862630607", "",
09317: "", "");
09318: mathtest(350, def, "12.2142434E+593908740",
09319: "5.27236571E-396050748", "1.22142434E+593908741",
09320: "1.22142434E+593908741", "6.43979581E+197857993",
09321: "2.3166533E+989959488", "", "", "");
09322: mathtest(351, def, "-28.591932", "-1.79153238E-817064576",
09323: "-28.5919320", "-28.5919320", "5.12233720E-817064575",
09324: "1.59594838E+817064577", "", "", "0.00122324372");
09325: mathtest(352, def, "590.849666", "753424.306E+277232744",
09326: "7.53424306E+277232749", "-7.53424306E+277232749",
09327: "4.45160500E+277232752", "7.84219014E-277232748", "0",
09328: "590.849666", "1.48530607E+22");
09329: mathtest(353, def, "1.7270628", "-1325026.67", "-1325024.94",
09330: "1325028.40", "-2288404.27", "-0.00000130341739", "0",
09331: "1.7270628", "2.09260036E-314440");
09332: mathtest(354, def, "33402118.", "-5534.83745", "33396583.2",
09333: "33407652.8", "-1.84875294E+11", "-6034.8869", "-6034",
09334: "4908.82670", "8.14473913E-41645");
09335: mathtest(355, def, "-439842.506", "-775110.807", "-1214953.31",
09336: "335268.301", "3.40926680E+11", "0.567457584", "0",
09337: "-439842.506", "-1.84678472E-4374182");
09338: mathtest(356, def, "-248664.779", "-440890.44E+666433944",
09339: "-4.40890440E+666433949", "4.40890440E+666433949",
09340: "1.09633924E+666433955", "5.64005831E-666433945", "0",
09341: "-248664.779", "2.61542877E-22");
09342: mathtest(357, def, "-14161.9142", "8306.49493", "-5855.4193",
09343: "-22468.4091", "-117635869", "-1.70492059", "-1",
09344: "-5855.41927", "1.65573372E+34479");
09345: mathtest(358, def, "-6417227.13", "16679.8842", "-6400547.25",
09346: "-6433907.01", "-1.07038605E+11", "-384.728518",
09347: "-384", "-12151.5972", "3.58767978E+113546");
09348: mathtest(359, def, "514825024.", "-25.0446345E-103809457",
09349: "514825024", "514825024", "-1.28936046E-103809447",
09350: "-2.05563002E+103809464", "", "", "7.32860062E-27");
09351: mathtest(360, def, "525948196", "219450390", "745398586",
09352: "306497806", "1.15419537E+17", "2.39666102", "2",
09353: "87047416", "");
09354: mathtest(361, def, "-638509.181", "45580189.0E+269212559",
09355: "4.55801890E+269212566", "-4.55801890E+269212566",
09356: "-2.91033691E+269212572", "-1.40084803E-269212561",
09357: "0", "-638509.181", "-1.06129405E+29");
09358: mathtest(362, def, "330590422", "74.359928E+535377965",
09359: "7.43599280E+535377966", "-7.43599280E+535377966",
09360: "2.45826800E+535377975", "4.44581418E-535377959", "0",
09361: "330590422", "4.31550742E+59");
09362: mathtest(363, def, "-3.48593871E-940579904",
09363: "-20265.9640E-322988987", "-2.02659640E-322988983",
09364: "2.02659640E-322988983", "", "1.72009519E-617590921",
09365: "0", "-3.48593871E-940579904", "");
09366: mathtest(364, def, "-328103480.", "-721.949371E-923938665",
09367: "-328103480", "-328103480", "2.36874101E-923938654",
09368: "4.54468822E+923938670", "", "", "-2.4430038E-60");
09369: mathtest(365, def, "-1857.01448", "19081578.1", "19079721.1",
09370: "-19083435.1", "-3.54347668E+10", "-0.0000973197537",
09371: "0", "-1857.01448", "8.44397087E+62374153");
09372: mathtest(366, def, "347.28720E+145930771",
09373: "-62821.9906E-676564106", "3.47287200E+145930773",
09374: "3.47287200E+145930773", "-2.18172732E-530633328",
09375: "-5.52811518E+822494874", "", "",
09376: "5.69990135E-875584642");
09377: mathtest(367, def, "-643.211399E+441807003", "-50733419.2",
09378: "-6.43211399E+441807005", "-6.43211399E+441807005",
09379: "3.26323135E+441807013", "1.26782584E+441806998", "",
09380: "", "");
09381: mathtest(368, def, "-53991661.4E-843339554", "20718.7346",
09382: "20718.7346", "-20718.7346", "-1.11863890E-843339542",
09383: "-2.60593431E-843339551", "0",
09384: "-5.39916614E-843339547", "");
09385: mathtest(369, def, "-900181424", "-105763982.",
09386: "-1.00594541E+9", "-794417442", "9.52067719E+16",
09387: "8.51122856", "8", "-54069568", "1.32627061E-947045602");
09388: mathtest(370, def, "94218.7462E+563233951",
09389: "19262.6382E+765263890", "1.92626382E+765263894",
09390: "-1.92626382E+765263894", "", "4.89126906E-202029939",
09391: "0", "9.42187462E+563233955", "");
09392: mathtest(371, def, "28549.271E+921331828", "-2150590.40",
09393: "2.85492710E+921331832", "2.85492710E+921331832",
09394: "-6.13977881E+921331838", "-1.32750853E+921331826", "",
09395: "", "");
09396: mathtest(372, def, "810.7080E+779625763", "5957.94044",
09397: "8.10708000E+779625765", "8.10708000E+779625765",
09398: "4.83014998E+779625769", "1.36071854E+779625762", "",
09399: "", "");
09400: mathtest(373, def, "-23.7357549E+77116908",
09401: "351.100649E+864348022", "3.51100649E+864348024",
09402: "-3.51100649E+864348024", "-8.33363895E+941464933",
09403: "-6.7603848E-787231116", "0", "-2.37357549E+77116909",
09404: "3.17403853E+308467637");
09405: mathtest(374, def, "40216102.2E+292724544", "661.025962",
09406: "4.02161022E+292724551", "4.02161022E+292724551",
09407: "2.65838876E+292724554", "6.08389148E+292724548", "",
09408: "", "");
09409: mathtest(375, def, "22785024.3E+783719168",
09410: "399.505989E+137478666", "2.27850243E+783719175",
09411: "2.27850243E+783719175", "9.10275367E+921197843",
09412: "5.70329981E+646240506", "", "", "");
09413: mathtest(376, def, "515.591819E+821371364",
09414: "-692137914.E-149498690", "5.15591819E+821371366",
09415: "5.15591819E+821371366", "-3.56860646E+671872685",
09416: "-7.44926421E+970870047", "", "", "");
09417: mathtest(377, def, "-536883072E+477911251", "624996.301",
09418: "-5.36883072E+477911259", "-5.36883072E+477911259",
09419: "-3.35549934E+477911265", "-8.59017999E+477911253", "",
09420: "", "");
09421: mathtest(378, def, "-399492.914E-334369192",
09422: "5202119.87E+442442258", "5.20211987E+442442264",
09423: "-5.20211987E+442442264", "-2.07821003E+108073078",
09424: "-7.67942539E-776811452", "0",
09425: "-3.99492914E-334369187", "");
09426: mathtest(379, def, "762.071184", "9851631.37", "9852393.44",
09427: "-9850869.30", "7.50764438E+9", "0.0000773548213", "0",
09428: "762.071184", "4.02198436E+28392356");
09429: mathtest(380, def, "5626.12471", "72989818.3", "72995444.4",
09430: "-72984192.2", "4.10649820E+11", "0.0000770809524",
09431: "0", "5626.12471", "1.79814757E+273727098");
09432: mathtest(381, def, "-47207260.1", "-2073.3152", "-47209333.4",
09433: "-47205186.8", "9.78755299E+10", "22768.9741", "22768",
09434: "-2019.6264", "-6.02238319E-15909");
09435: mathtest(382, def, "207.740860", "-51.0390090", "156.701851",
09436: "258.779869", "-10602.8876", "-4.07023694", "-4",
09437: "3.5848240", "6.40297515E-119");
09438: mathtest(383, def, "-572.812464E-745934021",
09439: "-182805872.E+604508681", "-1.82805872E+604508689",
09440: "1.82805872E+604508689", "1.04713482E-141425329", "",
09441: "0", "-5.72812464E-745934019", "");
09442: mathtest(384, def, "-6418504E+3531407", "8459416.1",
09443: "-6.41850400E+3531413", "-6.41850400E+3531413",
09444: "-5.42967961E+3531420", "-7.58740784E+3531406", "", "",
09445: "");
09446: mathtest(385, def, "280689.531", "-128212543", "-127931854",
09447: "128493233", "-3.59879186E+13", "-0.00218925173", "0",
09448: "280689.531", "1.42173809E-698530938");
09449: mathtest(386, def, "15.803551E-783422793",
09450: "239108038E-489186308", "2.39108038E-489186300",
09451: "-2.39108038E-489186300", "", "6.60937672E-294236493",
09452: "0", "1.5803551E-783422792", "");
09453: mathtest(387, def, "26.515922", "-9418242.96E-105481628",
09454: "26.5159220", "26.5159220", "-2.49733396E-105481620",
09455: "-2.81537885E+105481622", "", "", "1.54326108E-13");
09456: mathtest(388, def, "-88.1094557", "-54029934.1", "-54030022.2",
09457: "54029846.0", "4.76054809E+9", "0.0000016307526", "0",
09458: "-88.1094557", "5.05289826E-105089439");
09459: mathtest(389, def, "6770.68602E-498420397",
09460: "-6.11248908E-729616908", "6.77068602E-498420394",
09461: "6.77068602E-498420394", "", "-1.10768067E+231196514",
09462: "", "", "");
09463: mathtest(390, def, "-892973818.E-781904441", "555201299.",
09464: "555201299", "-555201299", "-4.95780224E-781904424",
09465: "-1.60837847E-781904441", "0",
09466: "-8.92973818E-781904433", "");
09467: mathtest(391, def, "670175802E+135430680", "27355195.4",
09468: "6.70175802E+135430688", "6.70175802E+135430688",
09469: "1.83327900E+135430696", "2.44990318E+135430681", "",
09470: "", "");
09471: mathtest(392, def, "-440950.26", "205.477469E-677345561",
09472: "-440950.260", "-440950.260", "-9.06053434E-677345554",
09473: "-2.14597864E+677345564", "", "", "1.94437132E+11");
09474: mathtest(393, def, "-8.2335779", "573665010E+742722075",
09475: "5.73665010E+742722083", "-5.73665010E+742722083",
09476: "-4.72331555E+742722084", "-1.43525886E-742722083",
09477: "0", "-8.2335779", "311552.753");
09478: mathtest(394, def, "452943.863", "7022.23629", "459966.099",
09479: "445921.627", "3.18067883E+9", "64.5013703", "64",
09480: "3520.74044", "5.54158976E+39716");
09481: mathtest(395, def, "62874.1079", "-52719654.1", "-52656780.0",
09482: "52782528.2", "-3.31470122E+12", "-0.0011926123", "0",
09483: "62874.1079", "1.18819936E-252973775");
09484: mathtest(396, def, "-7428.41741E+609772037", "-46024819.3",
09485: "-7.42841741E+609772040", "-7.42841741E+609772040",
09486: "3.41891569E+609772048", "1.61400251E+609772033", "",
09487: "", "");
09488: mathtest(397, def, "2.27959297", "41937.019", "41939.2986",
09489: "-41934.7394", "95599.3337", "0.0000543575348", "0",
09490: "2.27959297", "2.89712423E+15007");
09491: mathtest(398, def, "508692408E-671967782", "8491989.20",
09492: "8491989.20", "-8491989.20", "4.31981043E-671967767",
09493: "5.99026207E-671967781", "0", "5.08692408E-671967774",
09494: "");
09495: mathtest(399, def, "940.533705E-379310421",
09496: "-4.01176961E+464620037", "-4.01176961E+464620037",
09497: "4.01176961E+464620037", "-3.77320453E+85309619",
09498: "-2.34443599E-843930456", "0", "9.40533705E-379310419",
09499: "");
09500: mathtest(400, def, "97.0649652", "-92.4485649E-151989098",
09501: "97.0649652", "97.0649652", "-8.97351673E-151989095",
09502: "-1.0499348E+151989098", "", "", "1.30748728E-18");
09503: mathtest(401, def, "297544.536E+360279473", "8.80275007",
09504: "2.97544536E+360279478", "2.97544536E+360279478",
09505: "2.61921019E+360279479", "3.38013159E+360279477", "",
09506: "", "");
09507: mathtest(402, def, "-28861028.", "82818.820E+138368758",
09508: "8.28188200E+138368762", "-8.28188200E+138368762",
09509: "-2.39023628E+138368770", "-3.48483932E-138368756",
09510: "0", "-28861028", "4.81387013E+59");
09511: mathtest(403, def, "36.2496238E+68828039", "49243.00",
09512: "3.62496238E+68828040", "3.62496238E+68828040",
09513: "1.78504022E+68828045", "7.36137599E+68828035", "", "",
09514: "");
09515: mathtest(404, def, "22.447828E-476014683", "-56067.5520",
09516: "-56067.5520", "56067.5520", "-1.25859476E-476014677",
09517: "-4.00371109E-476014687", "0", "2.2447828E-476014682",
09518: "");
09519: mathtest(405, def, "282688.791E+75011952", "5.99789051",
09520: "2.82688791E+75011957", "2.82688791E+75011957",
09521: "1.69553642E+75011958", "4.7131369E+75011956", "", "",
09522: "5.10330507E+450071744");
09523: mathtest(406, def, "-981.860310E-737387002", "-994046289",
09524: "-994046289", "994046289", "9.76014597E-737386991",
09525: "9.87741035E-737387009", "0", "-9.81860310E-737387000",
09526: "");
09527: mathtest(407, def, "-702.91210", "-6444903.55", "-6445606.46",
09528: "6444200.64", "4.53020069E+9", "0.000109064797", "0",
09529: "-702.91210", "1.70866703E-18348004");
09530: mathtest(408, def, "972456720E-17536823", "16371.2590",
09531: "16371.2590", "-16371.2590", "1.59203408E-17536810",
09532: "5.94002404E-17536819", "0", "9.72456720E-17536815", "");
09533: mathtest(409, def, "71471.2045", "-74303278.4", "-74231807.2",
09534: "74374749.6", "-5.31054481E+12", "-0.00096188494", "0",
09535: "71471.2045", "2.14535374E-360677853");
09536: mathtest(410, def, "643.103951E+439708441", "788251925.",
09537: "6.43103951E+439708443", "6.43103951E+439708443",
09538: "5.06927927E+439708452", "8.15860933E+439708434", "",
09539: "", "");
09540: mathtest(411, def, "4.30838663", "-7.43110827", "-3.12272164",
09541: "11.7394949", "-32.0160875", "-0.579777131", "0",
09542: "4.30838663", "0.0000362908645");
09543: mathtest(412, def, "823.678025", "-513.581840E-324453141",
09544: "823.678025", "823.678025", "-4.23026076E-324453136",
09545: "-1.60379118E+324453141", "", "", "2.63762228E-15");
09546: mathtest(413, def, "4461.81162", "3.22081680", "4465.03244",
09547: "4458.59080", "14370.6778", "1385.30438", "1385",
09548: "0.98035200", "8.8824688E+10");
09549: mathtest(414, def, "-4458527.10", "-99072605", "-103531132",
09550: "94614077.9", "4.41717894E+14", "0.0450026231", "0",
09551: "-4458527.10", "-6.23928099E-658752715");
09552: mathtest(415, def, "-577964618", "487424368.", "-90540250",
09553: "-1.06538899E+9", "-2.81714039E+17", "-1.18575241",
09554: "-1", "-90540250", "");
09555: mathtest(416, def, "-867.036184", "-57.1768608", "-924.213045",
09556: "-809.859323", "49574.4072", "15.1641096", "15",
09557: "-9.3832720", "-3.40312837E-168");
09558: mathtest(417, def, "771871921E-330504770", "5.34285236",
09559: "5.34285236", "-5.34285236", "4.12399771E-330504761",
09560: "1.44468136E-330504762", "0", "7.71871921E-330504762",
09561: "");
09562: mathtest(418, def, "-338683.062E-728777518", "166441931",
09563: "166441931", "-166441931", "-5.63710628E-728777505",
09564: "-2.03484218E-728777521", "0",
09565: "-3.38683062E-728777513", "");
09566: mathtest(419, def, "-512568743", "-416376887.E-965945295",
09567: "-512568743", "-512568743", "2.13421778E-965945278",
09568: "1.23102112E+965945295", "", "", "1.44874358E-35");
09569: mathtest(420, def, "7447181.99", "5318438.52", "12765620.5",
09570: "2128743.47", "3.96073796E+13", "1.40025723", "1",
09571: "2128743.47", "1.21634782E+36548270");
09572: mathtest(421, def, "54789.8207", "93165435.2", "93220225.0",
09573: "-93110645.4", "5.10451749E+12", "0.000588091716", "0",
09574: "54789.8207", "3.80769825E+441483035");
09575: mathtest(422, def, "41488.5960", "146.797094", "41635.3931",
09576: "41341.7989", "6090405.33", "282.625459", "282",
09577: "91.815492", "6.84738153E+678");
09578: mathtest(423, def, "785741.663E+56754529", "-461.531732",
09579: "7.85741663E+56754534", "7.85741663E+56754534",
09580: "-3.62644711E+56754537", "-1.70246509E+56754532", "",
09581: "", "");
09582: mathtest(424, def, "-4.95436786", "-3132.4233", "-3137.37767",
09583: "3127.46893", "15519.1773", "0.0015816406", "0",
09584: "-4.95436786", "1.98062422E-2177");
09585: mathtest(425, def, "77321.8478E+404626874", "82.4797688",
09586: "7.73218478E+404626878", "7.73218478E+404626878",
09587: "6.37748813E+404626880", "9.3746441E+404626876", "",
09588: "", "");
09589: mathtest(426, def, "-7.99307725", "-29153.7273", "-29161.7204",
09590: "29145.7342", "233027.994", "0.000274169994", "0",
09591: "-7.99307725", "1.88688028E-26318");
09592: mathtest(427, def, "-61.6337401E+474999517", "5254.87092",
09593: "-6.16337401E+474999518", "-6.16337401E+474999518",
09594: "-3.23877349E+474999522", "-1.1728878E+474999515", "",
09595: "", "");
09596: mathtest(428, def, "-16.4043088", "35.0064812", "18.6021724",
09597: "-51.4107900", "-574.257128", "-0.468607762", "0",
09598: "-16.4043088", "-3.33831843E+42");
09599: mathtest(429, def, "-8.41156520", "-56508958.9", "-56508967.3",
09600: "56508950.5", "475328792", "1.48853657E-7", "0",
09601: "-8.41156520", "-8.86365458E-52263827");
09602: mathtest(430, def, "-360165.79E+503559835", "-196688.515",
09603: "-3.60165790E+503559840", "-3.60165790E+503559840",
09604: "7.08404744E+503559845", "1.83114805E+503559835", "",
09605: "", "");
09606: mathtest(431, def, "-653236480.E+565648495", "-930.445274",
09607: "-6.53236480E+565648503", "-6.53236480E+565648503",
09608: "6.07800796E+565648506", "7.02068674E+565648500", "",
09609: "", "");
09610: mathtest(432, def, "-3.73342903", "855.029289", "851.295860",
09611: "-858.762718", "-3192.19117", "-0.00436643408", "0",
09612: "-3.73342903", "-1.41988961E+489");
09613: mathtest(433, def, "-5.14890532E+562048011",
09614: "10847127.8E-390918910", "-5.14890532E+562048011",
09615: "-5.14890532E+562048011", "-5.58508340E+171129108",
09616: "-4.74679142E+952966914", "", "",
09617: "-5.14890532E+562048011");
09618: mathtest(434, def, "653311907", "-810.036965E+744537823",
09619: "-8.10036965E+744537825", "8.10036965E+744537825",
09620: "-5.29206794E+744537834", "-8.06521104E-744537818",
09621: "0", "653311907", "3.01325171E-71");
09622: mathtest(435, def, "-1.31557907", "98.9139300E-579281802",
09623: "-1.31557907", "-1.31557907", "-1.30129096E-579281800",
09624: "-1.33002406E+579281800", "", "", "15.529932");
09625: mathtest(436, def, "-875192389", "-72071565.6", "-947263955",
09626: "-803120823", "6.30764857E+16", "12.1433797", "12",
09627: "-10333601.8", "1.25564408E-644471405");
09628: mathtest(437, def, "-72838078.8", "-391.398423", "-72838470.2",
09629: "-72837687.4", "2.85087092E+10", "186097.017",
09630: "186097", "-6.474969", "-6.574057E-3075");
09631: mathtest(438, def, "29186560.9", "-79.7419988", "29186481.2",
09632: "29186640.6", "-2.32739470E+9", "-366012.407",
09633: "-366012", "32.4352144", "6.10050869E-598");
09634: mathtest(439, def, "-329801660E-730249465", "-6489.9256",
09635: "-6489.92560", "6489.92560", "2.14038824E-730249453",
09636: "5.08174793E-730249461", "0", "-3.29801660E-730249457",
09637: "");
09638: mathtest(440, def, "91.8429117E+103164883", "7131455.16",
09639: "9.18429117E+103164884", "9.18429117E+103164884",
09640: "6.54973607E+103164891", "1.28785654E+103164878", "",
09641: "", "");
09642: mathtest(441, def, "3943866.38E+150855113", "-31927007.3",
09643: "3.94386638E+150855119", "3.94386638E+150855119",
09644: "-1.25915851E+150855127", "-1.23527594E+150855112", "",
09645: "", "");
09646: mathtest(442, def, "-7002.0468E-795962156", "-5937891.05",
09647: "-5937891.05", "5937891.05", "4.15773910E-795962146",
09648: "1.17921443E-795962159", "0", "-7.0020468E-795962153",
09649: "");
09650: mathtest(443, def, "696504605.", "54506.4617", "696559111",
09651: "696450099", "3.79640016E+13", "12778.386", "12778",
09652: "21037.3974", "2.6008532E+481992");
09653: mathtest(444, def, "-5115.76467", "690.960979E+815126701",
09654: "6.90960979E+815126703", "-6.90960979E+815126703",
09655: "-3.53479376E+815126707", "-7.4038402E-815126701", "0",
09656: "-5115.76467", "-9.17009655E+25");
09657: mathtest(445, def, "-261.279392", "-613.079357", "-874.358749",
09658: "351.799965", "160185.002", "0.426175484", "0",
09659: "-261.279392", "-2.06318841E-1482");
09660: mathtest(446, def, "-591407763", "-80145822.8", "-671553586",
09661: "-511261940", "4.73988618E+16", "7.37914644", "7",
09662: "-30387003.4", "-2.79334522E-703030105");
09663: mathtest(447, def, "615630407", "-69.4661869", "615630338",
09664: "615630476", "-4.27654969E+10", "-8862303.15",
09665: "-8862303", "10.4375693", "3.44283102E-607");
09666: mathtest(448, def, "1078757.50", "27402569.0E-713742082",
09667: "1078757.50", "1078757.50", "2.95607268E-713742069",
09668: "3.93670207E+713742080", "", "", "1.25536924E+18");
09669: mathtest(449, def, "-4865.60358E-401116515", "66952.5315",
09670: "66952.5315", "-66952.5315", "-3.25764477E-401116507",
09671: "-7.26724363E-401116517", "0",
09672: "-4.86560358E-401116512", "");
09673: mathtest(450, def, "-87805.3921E-934896690", "-1875.14745",
09674: "-1875.14745", "1875.14745", "1.64648057E-934896682",
09675: "4.68258601E-934896689", "0", "-8.78053921E-934896686",
09676: "");
09677: mathtest(451, def, "-232540609.E+602702520", "68.0834223",
09678: "-2.32540609E+602702528", "-2.32540609E+602702528",
09679: "-1.58321605E+602702530", "-3.41552468E+602702526", "",
09680: "", "");
09681: mathtest(452, def, "-320610803.", "-863871235.",
09682: "-1.18448204E+9", "543260432", "2.76966450E+17",
09683: "0.37113263", "0", "-320610803", "");
09684: mathtest(453, def, "-303956364E+278139979",
09685: "229537.920E+479603725", "2.29537920E+479603730",
09686: "-2.29537920E+479603730", "-6.97695116E+757743717",
09687: "-1.3242098E-201463743", "0", "-3.03956364E+278139987",
09688: "9.23894712E+556279974");
09689: mathtest(454, def, "-439.747348", "74.9494457E-353117582",
09690: "-439.747348", "-439.747348", "-3.29588200E-353117578",
09691: "-5.86725284E+353117582", "", "", "-3.17996693E+18");
09692: mathtest(455, def, "-89702231.9", "1.28993993", "-89702230.6",
09693: "-89702233.2", "-115710491", "-69539852.1",
09694: "-69539852", "-0.07890964", "-89702231.9");
09695: mathtest(456, def, "-5856939.14", "-6743375.34", "-12600314.5",
09696: "886436.20", "3.94955390E+13", "0.868547107", "0",
09697: "-5856939.14", "-3.29213248E-45636942");
09698: mathtest(457, def, "733317.669E+100381349",
09699: "-13832.6792E+174055607", "-1.38326792E+174055611",
09700: "1.38326792E+174055611", "-1.01437481E+274436966",
09701: "-5.30134227E-73674257", "0", "7.33317669E+100381354",
09702: "1.36366549E-100381355");
09703: mathtest(458, def, "87.4798787E-80124704", "108497.32",
09704: "108497.320", "-108497.320", "9.49133239E-80124698",
09705: "8.06286079E-80124708", "0", "8.74798787E-80124703", "");
09706: mathtest(459, def, "-694562052", "310681.319E+549445264",
09707: "3.10681319E+549445269", "-3.10681319E+549445269",
09708: "-2.15787454E+549445278", "-2.23560932E-549445261",
09709: "0", "-694562052", "-3.35068155E+26");
09710: mathtest(460, def, "-9744135.85", "1797016.04", "-7947119.81",
09711: "-11541151.9", "-1.75103684E+13", "-5.42239782", "-5",
09712: "-759055.65", "3.83848006E+12558883");
09713: mathtest(461, def, "3625.87308", "-50.2208536E+658627487",
09714: "-5.02208536E+658627488", "5.02208536E+658627488",
09715: "-1.82094441E+658627492", "-7.21985554E-658627486",
09716: "0", "3625.87308", "1.5956477E-18");
09717: mathtest(462, def, "365347.52", "-3655414.47", "-3290066.95",
09718: "4020761.99", "-1.33549661E+12", "-0.099946948", "0",
09719: "365347.52", "1.02663257E-20333994");
09720: mathtest(463, def, "-19706333.6E-816923050", "-383858032.",
09721: "-383858032", "383858032", "7.56443443E-816923035",
09722: "5.1337557E-816923052", "0", "-1.97063336E-816923043",
09723: "");
09724: mathtest(464, def, "-86346.2616", "-98.8063785", "-86445.0680",
09725: "-86247.4552", "8531561.41", "873.893598", "873",
09726: "-88.2931695", "-2.05064086E-489");
09727: mathtest(465, def, "-445588.160E-496592215", "328.822976",
09728: "328.822976", "-328.822976", "-1.46519625E-496592207",
09729: "-1.35510044E-496592212", "0",
09730: "-4.45588160E-496592210", "");
09731: mathtest(466, def, "-9709213.71", "-34.6690137", "-9709248.38",
09732: "-9709179.04", "336608863", "280054.512", "280054",
09733: "-17.7472602", "-2.80903974E-245");
09734: mathtest(467, def, "742395536.", "-43533.6889", "742352002",
09735: "742439070", "-3.23192163E+13", "-17053.3569",
09736: "-17053", "15539.1883", "5.7622734E-386175");
09737: mathtest(468, def, "-878849193.", "-5842982.47E-972537342",
09738: "-878849193", "-878849193", "5.13510043E-972537327",
09739: "1.50411061E+972537344", "", "", "2.17027042E-54");
09740: mathtest(469, def, "-78014142.1", "-624658.522", "-78638800.6",
09741: "-77389483.6", "4.87321987E+13", "124.890863", "124",
09742: "-556485.372", "-7.86063865E-4929918");
09743: mathtest(470, def, "857039.371", "454.379672", "857493.751",
09744: "856584.991", "389421268", "1886.17454", "1886",
09745: "79.309608", "3.82253101E+2693");
09746: mathtest(471, def, "166534010.", "-173.012236", "166533837",
09747: "166534183", "-2.88124214E+10", "-962556.255",
09748: "-962556", "44.164784", "4.78620664E-1423");
09749: mathtest(472, def, "-810.879063", "43776.610", "42965.7309",
09750: "-44587.4891", "-35497536.5", "-0.0185231123", "0",
09751: "-810.879063", "-2.34758691E+127345");
09752: mathtest(473, def, "-327.127935", "93458944", "93458616.9",
09753: "-93459271.1", "-3.05730314E+10", "-0.00000350023145",
09754: "0", "-327.127935", "2.29323021E+235022854");
09755: mathtest(474, def, "539295218.", "-9587941.10E-309643098",
09756: "539295218", "539295218", "-5.17073079E-309643083",
09757: "-5.62472394E+309643099", "", "", "4.80545269E-88");
09758: mathtest(475, def, "-3862702.65", "879616.733", "-2983085.92",
09759: "-4742319.38", "-3.39769789E+12", "-4.3913474", "-4",
09760: "-344235.718", "-3.50650167E+5793941");
09761: mathtest(476, def, "-8.25290500", "992.091584E+256070257",
09762: "9.92091584E+256070259", "-9.92091584E+256070259",
09763: "-8.18763759E+256070260", "-8.31869268E-256070260",
09764: "0", "-8.25290500", "1.46577888E+9");
09765: mathtest(477, def, "546875205.", "447.52857E+557357101",
09766: "4.47528570E+557357103", "-4.47528570E+557357103",
09767: "2.44742278E+557357112", "1.22198948E-557357095", "0",
09768: "546875205", "8.94443542E+34");
09769: mathtest(478, def, "177623437", "-7779116.14", "169844321",
09770: "185402553", "-1.38175335E+15", "-22.83337", "-22",
09771: "6482881.92", "2.90085309E-64173820");
09772: mathtest(479, def, "377204735.", "13768.1401", "377218503",
09773: "377190967", "5.19340764E+12", "27396.9274", "27396",
09774: "12768.8204", "2.06065297E+118082");
09775: mathtest(480, def, "-2435.49239", "-11732.0640E-23331504",
09776: "-2435.49239", "-2435.49239", "2.85733526E-23331497",
09777: "2.07592832E+23331503", "", "", "-0.00041059459");
09778: mathtest(481, def, "-6128465.14E-137123294", "-5742264.27",
09779: "-5742264.27", "5742264.27", "3.51912664E-137123281",
09780: "1.06725585E-137123294", "0", "-6.12846514E-137123288",
09781: "");
09782: mathtest(482, def, "-2898065.44", "-5.11638105", "-2898070.56",
09783: "-2898060.32", "14827607.1", "566428.773", "566428",
09784: "-3.95461060", "-4.89169151E-33");
09785: mathtest(483, def, "1851395.31E+594383160", "-550301.475",
09786: "1.85139531E+594383166", "1.85139531E+594383166",
09787: "-1.01882557E+594383172", "-3.36432918E+594383160", "",
09788: "", "");
09789: mathtest(484, def, "536412589.E+379583977", "899.601161",
09790: "5.36412589E+379583985", "5.36412589E+379583985",
09791: "4.82557388E+379583988", "5.96278231E+379583982", "",
09792: "", "");
09793: mathtest(485, def, "185.85297", "867419480.", "867419666",
09794: "-867419294", "1.61212487E+11", "2.14259622E-7", "0",
09795: "185.85297", "");
09796: mathtest(486, def, "-5.26631053", "-3815941.35E+183291763",
09797: "-3.81594135E+183291769", "3.81594135E+183291769",
09798: "2.00959321E+183291770", "1.38008162E-183291769", "0",
09799: "-5.26631053", "0.00130009218");
09800: mathtest(487, def, "-8.11587021E-245942806",
09801: "4553.06753E+943412048", "4.55306753E+943412051",
09802: "-4.55306753E+943412051", "-3.69521051E+697469246", "",
09803: "0", "-8.11587021E-245942806", "");
09804: mathtest(488, def, "-405765.352", "854963231", "854557466",
09805: "-855368996", "-3.46914456E+14", "-0.000474599769",
09806: "0", "-405765.352", "");
09807: mathtest(489, def, "-159.609757", "-43356.7567", "-43516.3665",
09808: "43197.1470", "6920161.40", "0.00368131219", "0",
09809: "-159.609757", "-8.95397849E-95519");
09810: mathtest(490, def, "-564240.241E-501316672", "-557.781977",
09811: "-557.781977", "557.781977", "3.14723037E-501316664",
09812: "1.01157847E-501316669", "0", "-5.64240241E-501316667",
09813: "");
09814: mathtest(491, def, "318847.270", "582107878.E+399633412",
09815: "5.82107878E+399633420", "-5.82107878E+399633420",
09816: "1.85603508E+399633426", "5.47746014E-399633416", "0",
09817: "318847.270", "1.0507423E+33");
09818: mathtest(492, def, "-4426.59663", "95.1096765", "-4331.48695",
09819: "-4521.70631", "-421012.173", "-46.5420217", "-46",
09820: "-51.5515110", "-2.38037379E+346");
09821: mathtest(493, def, "6037.28310", "578264.105", "584301.388",
09822: "-572226.822", "3.49114411E+9", "0.010440356", "0",
09823: "6037.28310", "3.57279483E+2186324");
09824: mathtest(494, def, "-66.9556692", "-53.8519404", "-120.807610",
09825: "-13.1037288", "3605.69271", "1.24332881", "1",
09826: "-13.1037288", "2.55554086E-99");
09827: mathtest(495, def, "-92486.0222", "-59935.8544", "-152421.877",
09828: "-32550.1678", "5.54322876E+9", "1.5430834", "1",
09829: "-32550.1678", "1.83152656E-297647");
09830: mathtest(496, def, "852136219.E+917787351", "9246221.91",
09831: "8.52136219E+917787359", "8.52136219E+917787359",
09832: "7.87904058E+917787366", "9.21604767E+917787352", "",
09833: "", "");
09834: mathtest(497, def, "-2120096.16E-269253718", "9437.00514",
09835: "9437.00514", "-9437.00514", "-2.00073584E-269253708",
09836: "-2.24657731E-269253716", "0",
09837: "-2.12009616E-269253712", "");
09838: mathtest(498, def, "-524653.169E-865784226", "228054.698",
09839: "228054.698", "-228054.698", "-1.19649620E-865784215",
09840: "-2.30055848E-865784226", "0",
09841: "-5.24653169E-865784221", "");
09842: mathtest(499, def, "-288193133", "-312268737.", "-600461870",
09843: "24075604", "8.99937057E+16", "0.922901011", "0",
09844: "-288193133", "");
09845: mathtest(500, def, "-373484759E-113589964",
09846: "844101958E-852538240", "-3.73484759E-113589956",
09847: "-3.73484759E-113589956", "-3.15259216E-966128187",
09848: "-4.42464036E+738948275", "", "",
09849: "3.78602147E-908719644");
09850:
09851: summary("Arithmetic");
09852: }
09853:
09854: /* mathtest -- general arithmetic test routine
09855: Arg1 is test number
09856: Arg2 is MathContext
09857: Arg3 is left hand side (LHS)
09858: Arg4 is right hand side (RHS)
09859: Arg5 is the expected result for add
09860: Arg6 is the expected result for subtract
09861: Arg7 is the expected result for multiply
09862: Arg8 is the expected result for divide
09863: Arg9 is the expected result for integerDivide
09864: Arg10 is the expected result for remainder
09865: Arg11 is the expected result for power
09866:
09867: For power RHS, 0 is added to the number, any exponent is removed and
09868: the number is then rounded to an integer, using format(rhs+0,,0)
09869:
09870: If an error should result for an operation, the 'expected result' is
09871: an empty string.
09872: */
09873:
09874: private void mathtest(int test, com.ibm.icu.math.MathContext mc,
09875: java.lang.String slhs, java.lang.String srhs,
09876: java.lang.String add, java.lang.String sub,
09877: java.lang.String mul, java.lang.String div,
09878: java.lang.String idv, java.lang.String rem,
09879: java.lang.String pow) {
09880: com.ibm.icu.math.BigDecimal lhs;
09881: com.ibm.icu.math.BigDecimal rhs;
09882: java.lang.String res = null;
09883: java.lang.String sn = null;
09884: int e = 0;
09885:
09886: lhs = new com.ibm.icu.math.BigDecimal(slhs);
09887: rhs = new com.ibm.icu.math.BigDecimal(srhs);
09888:
09889: try {
09890: res = lhs.add(rhs, mc).toString();
09891: } catch (java.lang.ArithmeticException $137) {
09892: res = "";
09893: }
09894: mathtestcheck(test, lhs, rhs, "add", res, add);
09895:
09896: try {
09897: res = lhs.subtract(rhs, mc).toString();
09898: } catch (java.lang.ArithmeticException $138) {
09899: res = "";
09900: }
09901: mathtestcheck(test, lhs, rhs, "sub", res, sub);
09902:
09903: try {
09904: res = lhs.multiply(rhs, mc).toString();
09905: } catch (java.lang.ArithmeticException $139) {
09906: res = "";
09907: }
09908: mathtestcheck(test, lhs, rhs, "mul", res, mul);
09909:
09910: try {
09911: res = lhs.divide(rhs, mc).toString();
09912: } catch (java.lang.ArithmeticException $140) {
09913: res = "";
09914: }
09915: mathtestcheck(test, lhs, rhs, "div", res, div);
09916:
09917: try {
09918: res = lhs.divideInteger(rhs, mc).toString();
09919: } catch (java.lang.ArithmeticException $141) {
09920: res = "";
09921: }
09922: mathtestcheck(test, lhs, rhs, "idv", res, idv);
09923:
09924: try {
09925: res = lhs.remainder(rhs, mc).toString();
09926: } catch (java.lang.ArithmeticException $142) {
09927: res = "";
09928: }
09929: mathtestcheck(test, lhs, rhs, "rem", res, rem);
09930:
09931: try {
09932: // prepare an integer from the rhs
09933: // in Rexx:
09934: // n=rhs+0
09935: // e=pos('E', n)
09936: // if e>0 then n=left(n,e-1)
09937: // n=format(n,,0)
09938:
09939: sn = rhs.plus(mc).toString();
09940: e = sn.indexOf("E", 0);
09941: if (e > 0)
09942: sn = sn.substring(0, e);
09943: sn = (new com.ibm.icu.math.BigDecimal(sn)).format(-1, 0);
09944:
09945: res = lhs.pow(new com.ibm.icu.math.BigDecimal(sn), mc)
09946: .toString();
09947: } catch (java.lang.ArithmeticException $143) {
09948: res = "";
09949: }
09950: mathtestcheck(test, lhs, rhs, "pow", res, pow);
09951: return;
09952: }
09953:
09954: /* mathtestcheck -- check for general mathtest error
09955: Arg1 is test number
09956: Arg2 is left hand side (LHS)
09957: Arg3 is right hand side (RHS)
09958: Arg4 is the operation
09959: Arg5 is the actual result
09960: Arg6 is the expected result
09961: Show error message if a problem, otherwise return quietly
09962: */
09963:
09964: private void mathtestcheck(int test,
09965: com.ibm.icu.math.BigDecimal lhs,
09966: com.ibm.icu.math.BigDecimal rhs, java.lang.String op,
09967: java.lang.String got, java.lang.String want) {
09968: boolean flag;
09969: java.lang.String testnum;
09970:
09971: flag = want.equals((java.lang.Object) got);
09972:
09973: if ((!flag))
09974: say(">" + test + ">" + " " + lhs.toString() + " " + op
09975: + " " + rhs.toString() + " " + "=" + " " + want
09976: + " " + "[got" + " " + got + "]");
09977:
09978: testnum = "gen"
09979: + right((new com.ibm.icu.math.BigDecimal(test + 1000))
09980: .toString(), 3);
09981:
09982: (new Test(testnum)).ok = flag;
09983: return;
09984: }
09985:
09986: /* ------------------------------------------------------------------ */
09987: /* Support routines and minor classes follow */
09988: /* ------------------------------------------------------------------ */
09989:
09990: /* ----------------------------------------------------------------- */
09991: /* Method called to summarise pending tests */
09992: /* ----------------------------------------------------------------- */
09993: /* Arg1 is section name */
09994:
09995: private void summary(java.lang.String section) {
09996: int bad;
09997: int count;
09998: int i = 0;
09999: Test item = null;
10000: bad = 0;
10001: count = Tests.size();
10002: {
10003: int $144 = count;
10004: i = 0;
10005: i: for (; $144 > 0; $144--, i++) {
10006: item = (Test) (Tests.elementAt(i));
10007: if ((!item.ok)) {
10008: bad++;
10009: errln("Failed:" + " " + item.name);
10010: }
10011: }
10012: }/*i*/
10013: totalcount = totalcount + count;
10014: Tests = new java.util.Vector(100); // reinitialize
10015: if (bad == 0)
10016: say("OK" + " " + left(section, 14) + " "
10017: + right("[" + count + " " + "tests]", 12));
10018: else
10019: throw new DiagException(section + " " + "[failed" + " "
10020: + bad + " " + "of" + " " + count + " " + "tests]",
10021: bad);
10022: }
10023:
10024: /* ----------------------------------------------------------------- */
10025: /* right - Utility to do a 'right' on a Java String */
10026: /* ----------------------------------------------------------------- */
10027: /* Arg1 is string to right-justify */
10028: /* Arg2 is desired length */
10029:
10030: private static java.lang.String right(java.lang.String s, int len) {
10031: int slen;
10032: slen = s.length();
10033: if (slen == len)
10034: return s; // length just right
10035: if (slen > len)
10036: return s.substring(slen - len); // truncate on left
10037: // too short
10038: return (new java.lang.String(new char[len - slen])).replace(
10039: '\000', ' ').concat(s);
10040: }
10041:
10042: /* ----------------------------------------------------------------- */
10043: /* left - Utility to do a 'left' on a Java String */
10044: /* ----------------------------------------------------------------- */
10045: /* Arg1 is string to left-justify */
10046: /* Arg2 is desired length */
10047:
10048: private static java.lang.String left(java.lang.String s, int len) {
10049: int slen;
10050: slen = s.length();
10051: if (slen == len)
10052: return s; // length just right
10053: if (slen > len)
10054: return s.substring(0, len); // truncate on right
10055: // too short
10056: return s.concat((new java.lang.String(new char[len - slen]))
10057: .replace('\000', ' '));
10058: }
10059:
10060: /* ----------------------------------------------------------------- */
10061: /* say - Utility to do a display */
10062: /* ----------------------------------------------------------------- */
10063: /* Arg1 is string to display, omitted if none */
10064: /* [null or omitted gives blank line] */
10065: // this version doesn't heed continuation final character
10066: private void say() {
10067: say((java.lang.String) null);
10068: return;
10069: }
10070:
10071: private void say(java.lang.String s) {
10072: if (s == null)
10073: s = " ";
10074: logln(s);
10075: }
10076:
10077: /* ----------------------------------------------------------------- */
10078: /* Scaffolding for stand-alone run */
10079: /* ----------------------------------------------------------------- */
10080: /** Entry point for stand-alone run. It constructs a
10081: * <code>DiagBigDecimal</code> object and then invokes its
10082: * {@link #diagrun(boolean)} method to run the test
10083: * suite.
10084: *
10085: * @param args The command line argument string array.
10086: * if the first word is '<code>continue</code>' then try and run
10087: * all tests, otherwise stop after the first failing test group.
10088: */
10089: public static void main(String[] args) throws Exception {
10090: new DiagBigDecimal().run(args);
10091: }
10092:
10093: public void TestBigDecimal() {
10094: boolean $continue;
10095: int fails;
10096: $continue = false;
10097: fails = diagrun($continue); // and run the tests
10098: if (fails != 0) {
10099: errln("Diagnostic Tests for math failed. Number of errors: "
10100: + fails);
10101: }
10102: }
10103:
10104: /* ------------------------------------------------------------------ */
10105: /* Test -- represents a test and its status */
10106: /* ------------------------------------------------------------------ */
10107: /* Copyright IBM Corporation 1998, 2000. All rights reserved. */
10108: /* Author: Mike Cowlishaw */
10109: /* ------------------------------------------------------------------ */
10110: /* 1998.07.15 Initial version */
10111: /* 2000.03.27 Change to javadoc comments */
10112:
10113: /**
10114: * The <code>Test</code> class is used to record a specific test.
10115: * When constructed, it notes the name of the test and adds the test
10116: * to the list of tests held by the parent.
10117: *
10118: * Its <code>ok</flag> is assigned directly to record whether the
10119: * test succeeded (1) or failed (0).
10120: *
10121: * @see com.ibm.icu.math.BigDecimal
10122: * @version 1.00 2000.03.27
10123: * @author Mike Cowlishaw
10124: */
10125:
10126: public class Test {
10127: private final transient java.lang.String $0 = "DiagBigDecimal.nrx";
10128: /* properties shared transient */
10129: /** The name of the test. */
10130: transient java.lang.String name;
10131: /** Success flag; will be set to 1 (true) if the test succeeded, or 0
10132: * (false) if the test failed.
10133: */
10134: transient boolean ok;
10135:
10136: /**
10137: * Constructs a new <code>Test</code> with a specified name.
10138: *
10139: * @param testname The <code>String</code> naming the test.
10140: */
10141:
10142: public Test(java.lang.String testname) {
10143: super ();
10144: name = testname; // save the name
10145: DiagBigDecimal.this .Tests
10146: .addElement((java.lang.Object) this ); // and add to parent's list
10147: }
10148: }
10149:
10150: /* ------------------------------------------------------------------ */
10151: /* DiagException */
10152: /* ------------------------------------------------------------------ */
10153: /* Copyright IBM Corporation 1996, 2000. All rights reserved. */
10154: /* Author: Mike Cowlishaw */
10155: /* ------------------------------------------------------------------ */
10156: /* 1996.05.27 Initial version in NetRexx (as DiagX) */
10157: /* 1998.06.25 Copied from NetRexx test suite */
10158: /* 1999.07.03 Add fail count */
10159: /* 2000.03.27 Change to javadoc comments */
10160:
10161: /**
10162: * The <code>DiagException</code> class is used to signal the failure
10163: * of a test group. It records the number of failures in the group.
10164: *
10165: * @see com.ibm.icu.math.BigDecimal
10166: * @version 1.00 2000.03.27
10167: * @author Mike Cowlishaw
10168: */
10169:
10170: public static class DiagException extends
10171: java.lang.RuntimeException {
10172: private final transient java.lang.String $0 = "DiagBigDecimal.nrx";
10173:
10174: /* properties shared transient */
10175: /** the count of failed tests in the group which signalled this
10176: * exception.
10177: */
10178: transient int failcount = 0;
10179:
10180: // number of tests which failed
10181:
10182: /**
10183: * Constructs a new <code>DiagException</code> with a message and
10184: * failure count. This is thrown when a group of tests fails.
10185: *
10186: * @param message The <code>String</code> message describing the group.
10187: * @param fails The <code>int</code> number of failed tests in the group.
10188: */
10189:
10190: public DiagException(java.lang.String message, int fails) {
10191: super(message);
10192: failcount = fails;
10193: }
10194: }
10195: }
|