]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_4_2-src/main/classes/core/src/com/ibm/icu/math/MathContext.java
go
[Dictionary.git] / jars / icu4j-4_4_2-src / main / classes / core / src / com / ibm / icu / math / MathContext.java
1 /* Generated from 'MathContext.nrx' 8 Sep 2000 11:07:48 [v2.00] */\r
2 /* Options: Binary Comments Crossref Format Java Logo Strictargs Strictcase Trace2 Verbose3 */\r
3 package com.ibm.icu.math;\r
4 \r
5 /* ------------------------------------------------------------------ */\r
6 /* MathContext -- Math context settings                               */\r
7 /* ------------------------------------------------------------------ */\r
8 /* Copyright IBM Corporation, 1997, 2000, 2005, 2007.  All Rights Reserved. */\r
9 /*                                                                    */\r
10 /*   The MathContext object encapsulates the settings used by the     */\r
11 /*   BigDecimal class; it could also be used by other arithmetics.    */\r
12 /* ------------------------------------------------------------------ */\r
13 /* Notes:                                                             */\r
14 /*                                                                    */\r
15 /* 1. The properties are checked for validity on construction, so     */\r
16 /*    the BigDecimal class may assume that they are correct.          */\r
17 /* ------------------------------------------------------------------ */\r
18 /* Author:    Mike Cowlishaw                                          */\r
19 /* 1997.09.03 Initial version (edited from netrexx.lang.RexxSet)      */\r
20 /* 1997.09.12 Add lostDigits property                                 */\r
21 /* 1998.05.02 Make the class immutable and final; drop set methods    */\r
22 /* 1998.06.05 Add Round (rounding modes) property                     */\r
23 /* 1998.06.25 Rename from DecimalContext; allow digits=0              */\r
24 /* 1998.10.12 change to com.ibm.icu.math package                          */\r
25 /* 1999.02.06 add javadoc comments                                    */\r
26 /* 1999.03.05 simplify; changes from discussion with J. Bloch         */\r
27 /* 1999.03.13 1.00 release to IBM Centre for Java Technology          */\r
28 /* 1999.07.10 1.04 flag serialization unused                          */\r
29 /* 2000.01.01 1.06 copyright update                                   */\r
30 /* ------------------------------------------------------------------ */\r
31 \r
32 \r
33 \r
34 \r
35 /**\r
36  * The <code>MathContext</code> immutable class encapsulates the\r
37  * settings understood by the operator methods of the {@link BigDecimal}\r
38  * class (and potentially other classes).  Operator methods are those\r
39  * that effect an operation on a number or a pair of numbers.\r
40  * <p>\r
41  * The settings, which are not base-dependent, comprise:\r
42  * <ol>\r
43  * <li><code>digits</code>:\r
44  * the number of digits (precision) to be used for an operation\r
45  * <li><code>form</code>:\r
46  * the form of any exponent that results from the operation\r
47  * <li><code>lostDigits</code>:\r
48  * whether checking for lost digits is enabled\r
49  * <li><code>roundingMode</code>:\r
50  * the algorithm to be used for rounding.\r
51  * </ol>\r
52  * <p>\r
53  * When provided, a <code>MathContext</code> object supplies the\r
54  * settings for an operation directly.\r
55  * <p>\r
56  * When <code>MathContext.DEFAULT</code> is provided for a\r
57  * <code>MathContext</code> parameter then the default settings are used\r
58  * (<code>9, SCIENTIFIC, false, ROUND_HALF_UP</code>).\r
59  * <p>\r
60  * In the <code>BigDecimal</code> class, all methods which accept a\r
61  * <code>MathContext</code> object defaults) also have a version of the\r
62  * method which does not accept a MathContext parameter.  These versions\r
63  * carry out unlimited precision fixed point arithmetic (as though the\r
64  * settings were (<code>0, PLAIN, false, ROUND_HALF_UP</code>).\r
65  * <p>\r
66  * The instance variables are shared with default access (so they are\r
67  * directly accessible to the <code>BigDecimal</code> class), but must\r
68  * never be changed.\r
69  * <p>\r
70  * The rounding mode constants have the same names and values as the\r
71  * constants of the same name in <code>java.math.BigDecimal</code>, to\r
72  * maintain compatibility with earlier versions of\r
73  * <code>BigDecimal</code>.\r
74  *\r
75  * @see     BigDecimal\r
76  * @author  Mike Cowlishaw\r
77  * @stable ICU 2.0\r
78  */\r
79 \r
80 public final class MathContext implements java.io.Serializable{\r
81  //private static final java.lang.String $0="MathContext.nrx";\r
82  \r
83  /* ----- Properties ----- */\r
84  /* properties public constant */\r
85  /**\r
86   * Plain (fixed point) notation, without any exponent.\r
87   * Used as a setting to control the form of the result of a\r
88   * <code>BigDecimal</code> operation.\r
89   * A zero result in plain form may have a decimal part of one or\r
90   * more zeros.\r
91   *\r
92   * @see #ENGINEERING\r
93   * @see #SCIENTIFIC\r
94   * @stable ICU 2.0\r
95   */\r
96  public static final int PLAIN=0; // [no exponent]\r
97  \r
98  /**\r
99   * Standard floating point notation (with scientific exponential\r
100   * format, where there is one digit before any decimal point).\r
101   * Used as a setting to control the form of the result of a\r
102   * <code>BigDecimal</code> operation.\r
103   * A zero result in plain form may have a decimal part of one or\r
104   * more zeros.\r
105   *\r
106   * @see #ENGINEERING\r
107   * @see #PLAIN\r
108   * @stable ICU 2.0\r
109   */\r
110  public static final int SCIENTIFIC=1; // 1 digit before .\r
111  \r
112  /**\r
113   * Standard floating point notation (with engineering exponential\r
114   * format, where the power of ten is a multiple of 3).\r
115   * Used as a setting to control the form of the result of a\r
116   * <code>BigDecimal</code> operation.\r
117   * A zero result in plain form may have a decimal part of one or\r
118   * more zeros.\r
119   *\r
120   * @see #PLAIN\r
121   * @see #SCIENTIFIC\r
122   * @stable ICU 2.0\r
123   */\r
124  public static final int ENGINEERING=2; // 1-3 digits before .\r
125  \r
126  // The rounding modes match the original BigDecimal class values\r
127  /**\r
128   * Rounding mode to round to a more positive number.\r
129   * Used as a setting to control the rounding mode used during a\r
130   * <code>BigDecimal</code> operation.\r
131   * <p>\r
132   * If any of the discarded digits are non-zero then the result\r
133   * should be rounded towards the next more positive digit.\r
134   * @stable ICU 2.0\r
135   */\r
136  public static final int ROUND_CEILING=2;\r
137  \r
138  /**\r
139   * Rounding mode to round towards zero.\r
140   * Used as a setting to control the rounding mode used during a\r
141   * <code>BigDecimal</code> operation.\r
142   * <p>\r
143   * All discarded digits are ignored (truncated).  The result is\r
144   * neither incremented nor decremented.\r
145   * @stable ICU 2.0\r
146   */\r
147  public static final int ROUND_DOWN=1;\r
148  \r
149  /**\r
150   * Rounding mode to round to a more negative number.\r
151   * Used as a setting to control the rounding mode used during a\r
152   * <code>BigDecimal</code> operation.\r
153   * <p>\r
154   * If any of the discarded digits are non-zero then the result\r
155   * should be rounded towards the next more negative digit.\r
156   * @stable ICU 2.0\r
157   */\r
158  public static final int ROUND_FLOOR=3;\r
159  \r
160  /**\r
161   * Rounding mode to round to nearest neighbor, where an equidistant\r
162   * value is rounded down.\r
163   * Used as a setting to control the rounding mode used during a\r
164   * <code>BigDecimal</code> operation.\r
165   * <p>\r
166   * If the discarded digits represent greater than half (0.5 times)\r
167   * the value of a one in the next position then the result should be\r
168   * rounded up (away from zero).  Otherwise the discarded digits are\r
169   * ignored.\r
170   * @stable ICU 2.0\r
171   */\r
172  public static final int ROUND_HALF_DOWN=5;\r
173  \r
174  /**\r
175   * Rounding mode to round to nearest neighbor, where an equidistant\r
176   * value is rounded to the nearest even neighbor.\r
177   * Used as a setting to control the rounding mode used during a\r
178   * <code>BigDecimal</code> operation.\r
179   * <p>\r
180   * If the discarded digits represent greater than half (0.5 times)\r
181   * the value of a one in the next position then the result should be\r
182   * rounded up (away from zero).  If they represent less than half,\r
183   * then the result should be rounded down.\r
184   * <p>\r
185   * Otherwise (they represent exactly half) the result is rounded\r
186   * down if its rightmost digit is even, or rounded up if its\r
187   * rightmost digit is odd (to make an even digit).\r
188   * @stable ICU 2.0\r
189   */\r
190  public static final int ROUND_HALF_EVEN=6;\r
191  \r
192  /**\r
193   * Rounding mode to round to nearest neighbor, where an equidistant\r
194   * value is rounded up.\r
195   * Used as a setting to control the rounding mode used during a\r
196   * <code>BigDecimal</code> operation.\r
197   * <p>\r
198   * If the discarded digits represent greater than or equal to half\r
199   * (0.5 times) the value of a one in the next position then the result\r
200   * should be rounded up (away from zero).  Otherwise the discarded\r
201   * digits are ignored.\r
202   * @stable ICU 2.0\r
203   */\r
204  public static final int ROUND_HALF_UP=4;\r
205  \r
206  /**\r
207   * Rounding mode to assert that no rounding is necessary.\r
208   * Used as a setting to control the rounding mode used during a\r
209   * <code>BigDecimal</code> operation.\r
210   * <p>\r
211   * Rounding (potential loss of information) is not permitted.\r
212   * If any of the discarded digits are non-zero then an\r
213   * <code>ArithmeticException</code> should be thrown.\r
214   * @stable ICU 2.0\r
215   */\r
216  public static final int ROUND_UNNECESSARY=7;\r
217  \r
218  /**\r
219   * Rounding mode to round away from zero.\r
220   * Used as a setting to control the rounding mode used during a\r
221   * <code>BigDecimal</code> operation.\r
222   * <p>\r
223   * If any of the discarded digits are non-zero then the result will\r
224   * be rounded up (away from zero).\r
225   * @stable ICU 2.0\r
226   */\r
227  public static final int ROUND_UP=0;\r
228  \r
229  \r
230  /* properties shared */\r
231  /**\r
232   * The number of digits (precision) to be used for an operation.\r
233   * A value of 0 indicates that unlimited precision (as many digits\r
234   * as are required) will be used.\r
235   * <p>\r
236   * The {@link BigDecimal} operator methods use this value to\r
237   * determine the precision of results.\r
238   * Note that leading zeros (in the integer part of a number) are\r
239   * never significant.\r
240   * <p>\r
241   * <code>digits</code> will always be non-negative.\r
242   *\r
243   * @serial\r
244   */\r
245  int digits;\r
246  \r
247  /**\r
248   * The form of results from an operation.\r
249   * <p>\r
250   * The {@link BigDecimal} operator methods use this value to\r
251   * determine the form of results, in particular whether and how\r
252   * exponential notation should be used.\r
253   *\r
254   * @see #ENGINEERING\r
255   * @see #PLAIN\r
256   * @see #SCIENTIFIC\r
257   * @serial\r
258   */\r
259  int form; // values for this must fit in a byte\r
260  \r
261  /**\r
262   * Controls whether lost digits checking is enabled for an\r
263   * operation.\r
264   * Set to <code>true</code> to enable checking, or\r
265   * to <code>false</code> to disable checking.\r
266   * <p>\r
267   * When enabled, the {@link BigDecimal} operator methods check\r
268   * the precision of their operand or operands, and throw an\r
269   * <code>ArithmeticException</code> if an operand is more precise\r
270   * than the digits setting (that is, digits would be lost).\r
271   * When disabled, operands are rounded to the specified digits.\r
272   *\r
273   * @serial\r
274   */\r
275  boolean lostDigits;\r
276  \r
277  /**\r
278   * The rounding algorithm to be used for an operation.\r
279   * <p>\r
280   * The {@link BigDecimal} operator methods use this value to\r
281   * determine the algorithm to be used when non-zero digits have to\r
282   * be discarded in order to reduce the precision of a result.\r
283   * The value must be one of the public constants whose name starts\r
284   * with <code>ROUND_</code>.\r
285   *\r
286   * @see #ROUND_CEILING\r
287   * @see #ROUND_DOWN\r
288   * @see #ROUND_FLOOR\r
289   * @see #ROUND_HALF_DOWN\r
290   * @see #ROUND_HALF_EVEN\r
291   * @see #ROUND_HALF_UP\r
292   * @see #ROUND_UNNECESSARY\r
293   * @see #ROUND_UP\r
294   * @serial\r
295   */\r
296  int roundingMode;\r
297  \r
298  /* properties private constant */\r
299  // default settings\r
300  private static final int DEFAULT_FORM=SCIENTIFIC;\r
301  private static final int DEFAULT_DIGITS=9;\r
302  private static final boolean DEFAULT_LOSTDIGITS=false;\r
303  private static final int DEFAULT_ROUNDINGMODE=ROUND_HALF_UP;\r
304  \r
305  /* properties private constant */\r
306  \r
307  private static final int MIN_DIGITS=0; // smallest value for DIGITS.\r
308  private static final int MAX_DIGITS=999999999; // largest value for DIGITS.  If increased,\r
309  // the BigDecimal class may need update.\r
310  // list of valid rounding mode values, most common two first\r
311  private static final int ROUNDS[]=new int[]{ROUND_HALF_UP,ROUND_UNNECESSARY,ROUND_CEILING,ROUND_DOWN,ROUND_FLOOR,ROUND_HALF_DOWN,ROUND_HALF_EVEN,ROUND_UP};\r
312  \r
313  \r
314  private static final java.lang.String ROUNDWORDS[]=new java.lang.String[]{"ROUND_HALF_UP","ROUND_UNNECESSARY","ROUND_CEILING","ROUND_DOWN","ROUND_FLOOR","ROUND_HALF_DOWN","ROUND_HALF_EVEN","ROUND_UP"}; // matching names of the ROUNDS values\r
315  \r
316  \r
317  \r
318  \r
319  /* properties private constant unused */\r
320  \r
321  // Serialization version\r
322  private static final long serialVersionUID=7163376998892515376L;\r
323  \r
324  /* properties public constant */\r
325  /**\r
326   * A <code>MathContext</code> object initialized to the default\r
327   * settings for general-purpose arithmetic.  That is,\r
328   * <code>digits=9 form=SCIENTIFIC lostDigits=false\r
329   * roundingMode=ROUND_HALF_UP</code>.\r
330   *\r
331   * @see #SCIENTIFIC\r
332   * @see #ROUND_HALF_UP\r
333   * @stable ICU 2.0\r
334   */\r
335  public static final com.ibm.icu.math.MathContext DEFAULT=new com.ibm.icu.math.MathContext(DEFAULT_DIGITS,DEFAULT_FORM,DEFAULT_LOSTDIGITS,DEFAULT_ROUNDINGMODE);\r
336 \r
337  \r
338  \r
339  \r
340  /* ----- Constructors ----- */\r
341  \r
342  /**\r
343   * Constructs a new <code>MathContext</code> with a specified\r
344   * precision.\r
345   * The other settings are set to the default values\r
346   * (see {@link #DEFAULT}).\r
347   *\r
348   * An <code>IllegalArgumentException</code> is thrown if the\r
349   * <code>setdigits</code> parameter is out of range\r
350   * (&lt;0 or &gt;999999999).\r
351   *\r
352   * @param setdigits     The <code>int</code> digits setting\r
353   *                      for this <code>MathContext</code>.\r
354   * @throws IllegalArgumentException parameter out of range.\r
355   * @stable ICU 2.0\r
356   */\r
357  \r
358  public MathContext(int setdigits){\r
359   this(setdigits,DEFAULT_FORM,DEFAULT_LOSTDIGITS,DEFAULT_ROUNDINGMODE);\r
360   return;}\r
361 \r
362  \r
363  /**\r
364   * Constructs a new <code>MathContext</code> with a specified\r
365   * precision and form.\r
366   * The other settings are set to the default values\r
367   * (see {@link #DEFAULT}).\r
368   *\r
369   * An <code>IllegalArgumentException</code> is thrown if the\r
370   * <code>setdigits</code> parameter is out of range\r
371   * (&lt;0 or &gt;999999999), or if the value given for the\r
372   * <code>setform</code> parameter is not one of the appropriate\r
373   * constants.\r
374   *\r
375   * @param setdigits     The <code>int</code> digits setting\r
376   *                      for this <code>MathContext</code>.\r
377   * @param setform       The <code>int</code> form setting\r
378   *                      for this <code>MathContext</code>.\r
379   * @throws IllegalArgumentException parameter out of range.\r
380   * @stable ICU 2.0\r
381   */\r
382  \r
383  public MathContext(int setdigits,int setform){\r
384   this(setdigits,setform,DEFAULT_LOSTDIGITS,DEFAULT_ROUNDINGMODE);\r
385   return;}\r
386 \r
387  /**\r
388   * Constructs a new <code>MathContext</code> with a specified\r
389   * precision, form, and lostDigits setting.\r
390   * The roundingMode setting is set to its default value\r
391   * (see {@link #DEFAULT}).\r
392   *\r
393   * An <code>IllegalArgumentException</code> is thrown if the\r
394   * <code>setdigits</code> parameter is out of range\r
395   * (&lt;0 or &gt;999999999), or if the value given for the\r
396   * <code>setform</code> parameter is not one of the appropriate\r
397   * constants.\r
398   *\r
399   * @param setdigits     The <code>int</code> digits setting\r
400   *                      for this <code>MathContext</code>.\r
401   * @param setform       The <code>int</code> form setting\r
402   *                      for this <code>MathContext</code>.\r
403   * @param setlostdigits The <code>boolean</code> lostDigits\r
404   *                      setting for this <code>MathContext</code>.\r
405   * @throws IllegalArgumentException parameter out of range.\r
406   * @stable ICU 2.0\r
407   */\r
408  \r
409  public MathContext(int setdigits,int setform,boolean setlostdigits){\r
410   this(setdigits,setform,setlostdigits,DEFAULT_ROUNDINGMODE);\r
411   return;}\r
412 \r
413  /**\r
414   * Constructs a new <code>MathContext</code> with a specified\r
415   * precision, form, lostDigits, and roundingMode setting.\r
416   *\r
417   * An <code>IllegalArgumentException</code> is thrown if the\r
418   * <code>setdigits</code> parameter is out of range\r
419   * (&lt;0 or &gt;999999999), or if the value given for the\r
420   * <code>setform</code> or <code>setroundingmode</code> parameters is\r
421   * not one of the appropriate constants.\r
422   *\r
423   * @param setdigits       The <code>int</code> digits setting\r
424   *                        for this <code>MathContext</code>.\r
425   * @param setform         The <code>int</code> form setting\r
426   *                        for this <code>MathContext</code>.\r
427   * @param setlostdigits   The <code>boolean</code> lostDigits\r
428   *                        setting for this <code>MathContext</code>.\r
429   * @param setroundingmode The <code>int</code> roundingMode setting\r
430   *                        for this <code>MathContext</code>.\r
431   * @throws IllegalArgumentException parameter out of range.\r
432   * @stable ICU 2.0\r
433   */\r
434  \r
435  public MathContext(int setdigits,int setform,boolean setlostdigits,int setroundingmode){super();\r
436   \r
437   \r
438   // set values, after checking\r
439   if (setdigits!=DEFAULT_DIGITS) \r
440    {\r
441     if (setdigits<MIN_DIGITS) \r
442      throw new java.lang.IllegalArgumentException("Digits too small:"+" "+setdigits);\r
443     if (setdigits>MAX_DIGITS) \r
444      throw new java.lang.IllegalArgumentException("Digits too large:"+" "+setdigits);\r
445    }\r
446   {/*select*/\r
447   if (setform==SCIENTIFIC){\r
448    // [most common]\r
449   }else if (setform==ENGINEERING){\r
450   }else if (setform==PLAIN){\r
451   }else{\r
452    throw new java.lang.IllegalArgumentException("Bad form value:"+" "+setform);\r
453   }\r
454   }\r
455   if ((!(isValidRound(setroundingmode)))) \r
456    throw new java.lang.IllegalArgumentException("Bad roundingMode value:"+" "+setroundingmode);\r
457   digits=setdigits;\r
458   form=setform;\r
459   lostDigits=setlostdigits; // [no bad value possible]\r
460   roundingMode=setroundingmode;\r
461   return;}\r
462 \r
463  /**\r
464   * Returns the digits setting.\r
465   * This value is always non-negative.\r
466   *\r
467   * @return an <code>int</code> which is the value of the digits\r
468   *         setting\r
469   * @stable ICU 2.0\r
470   */\r
471  \r
472  public int getDigits(){\r
473   return digits;\r
474   }\r
475 \r
476  /**\r
477   * Returns the form setting.\r
478   * This will be one of\r
479   * {@link #ENGINEERING},\r
480   * {@link #PLAIN}, or\r
481   * {@link #SCIENTIFIC}.\r
482   *\r
483   * @return an <code>int</code> which is the value of the form setting\r
484   * @stable ICU 2.0\r
485   */\r
486  \r
487  public int getForm(){\r
488   return form;\r
489   }\r
490 \r
491  /**\r
492   * Returns the lostDigits setting.\r
493   * This will be either <code>true</code> (enabled) or\r
494   * <code>false</code> (disabled).\r
495   *\r
496   * @return a <code>boolean</code> which is the value of the lostDigits\r
497   *           setting\r
498   * @stable ICU 2.0\r
499   */\r
500  \r
501  public boolean getLostDigits(){\r
502   return lostDigits;\r
503   }\r
504 \r
505  /**\r
506   * Returns the roundingMode setting.\r
507   * This will be one of\r
508   * {@link  #ROUND_CEILING},\r
509   * {@link  #ROUND_DOWN},\r
510   * {@link  #ROUND_FLOOR},\r
511   * {@link  #ROUND_HALF_DOWN},\r
512   * {@link  #ROUND_HALF_EVEN},\r
513   * {@link  #ROUND_HALF_UP},\r
514   * {@link  #ROUND_UNNECESSARY}, or\r
515   * {@link  #ROUND_UP}.\r
516   *\r
517   * @return an <code>int</code> which is the value of the roundingMode\r
518   *         setting\r
519   * @stable ICU 2.0\r
520   */\r
521  \r
522  public int getRoundingMode(){\r
523   return roundingMode;\r
524   }\r
525 \r
526  /** Returns the <code>MathContext</code> as a readable string.\r
527   * The <code>String</code> returned represents the settings of the\r
528   * <code>MathContext</code> object as four blank-delimited words\r
529   * separated by a single blank and with no leading or trailing blanks,\r
530   * as follows:\r
531   * <ol>\r
532   * <li>\r
533   * <code>digits=</code>, immediately followed by\r
534   * the value of the digits setting as a numeric word.\r
535   * <li>\r
536   * <code>form=</code>, immediately followed by\r
537   * the value of the form setting as an uppercase word\r
538   * (one of <code>SCIENTIFIC</code>, <code>PLAIN</code>, or\r
539   * <code>ENGINEERING</code>).\r
540   * <li>\r
541   * <code>lostDigits=</code>, immediately followed by\r
542   * the value of the lostDigits setting\r
543   * (<code>1</code> if enabled, <code>0</code> if disabled).\r
544   * <li>\r
545   * <code>roundingMode=</code>, immediately followed by\r
546   * the value of the roundingMode setting as a word.\r
547   * This word will be the same as the name of the corresponding public\r
548   * constant.\r
549   * </ol>\r
550   * <p>\r
551   * For example:\r
552   * <br><code>\r
553   * digits=9 form=SCIENTIFIC lostDigits=0 roundingMode=ROUND_HALF_UP\r
554   * </code>\r
555   * <p>\r
556   * Additional words may be appended to the result of\r
557   * <code>toString</code> in the future if more properties are added\r
558   * to the class.\r
559   *\r
560   * @return a <code>String</code> representing the context settings.\r
561   * @stable ICU 2.0\r
562   */\r
563  \r
564  public java.lang.String toString(){\r
565   java.lang.String formstr=null;\r
566   int r=0;\r
567   java.lang.String roundword=null;\r
568   {/*select*/\r
569   if (form==SCIENTIFIC)\r
570    formstr="SCIENTIFIC";\r
571   else if (form==ENGINEERING)\r
572    formstr="ENGINEERING";\r
573   else{\r
574    formstr="PLAIN";/* form=PLAIN */\r
575   }\r
576   }\r
577   {int $1=ROUNDS.length;r=0;r:for(;$1>0;$1--,r++){\r
578    if (roundingMode==ROUNDS[r]) \r
579     {\r
580      roundword=ROUNDWORDS[r];\r
581      break r;\r
582     }\r
583    }\r
584   }/*r*/\r
585   return "digits="+digits+" "+"form="+formstr+" "+"lostDigits="+(lostDigits?"1":"0")+" "+"roundingMode="+roundword;\r
586   }\r
587 \r
588  \r
589  /* <sgml> Test whether round is valid. </sgml> */\r
590  // This could be made shared for use by BigDecimal for setScale.\r
591  \r
592  private static boolean isValidRound(int testround){\r
593   int r=0;\r
594   {int $2=ROUNDS.length;for(r=0;$2>0;$2--,r++){\r
595    if (testround==ROUNDS[r]) \r
596     return true;\r
597    }\r
598   }/*r*/\r
599   return false;\r
600   }\r
601  }\r