Java Doc for MathContext.java in  » Internationalization-Localization » icu4j » com » ibm » icu » math » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Internationalization Localization » icu4j » com.ibm.icu.math 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.ibm.icu.math.MathContext

MathContext
final public class MathContext implements java.io.Serializable(Code)
The MathContext immutable class encapsulates the settings understood by the operator methods of the BigDecimal class (and potentially other classes). Operator methods are those that effect an operation on a number or a pair of numbers.

The settings, which are not base-dependent, comprise:

  1. digits: the number of digits (precision) to be used for an operation
  2. form: the form of any exponent that results from the operation
  3. lostDigits: whether checking for lost digits is enabled
  4. roundingMode: the algorithm to be used for rounding.

When provided, a MathContext object supplies the settings for an operation directly.

When MathContext.DEFAULT is provided for a MathContext parameter then the default settings are used (9, SCIENTIFIC, false, ROUND_HALF_UP).

In the BigDecimal class, all methods which accept a MathContext object defaults) also have a version of the method which does not accept a MathContext parameter. These versions carry out unlimited precision fixed point arithmetic (as though the settings were (0, PLAIN, false, ROUND_HALF_UP).

The instance variables are shared with default access (so they are directly accessible to the BigDecimal class), but must never be changed.

The rounding mode constants have the same names and values as the constants of the same name in java.math.BigDecimal, to maintain compatibility with earlier versions of BigDecimal.
See Also:   BigDecimal
author:
   Mike Cowlishaw



Field Summary
final public static  com.ibm.icu.math.MathContextDEFAULT
     A MathContext object initialized to the default settings for general-purpose arithmetic.
final public static  intENGINEERING
     Standard floating point notation (with engineering exponential format, where the power of ten is a multiple of 3).
final public static  intPLAIN
     Plain (fixed point) notation, without any exponent.
final public static  intROUND_CEILING
     Rounding mode to round to a more positive number.
final public static  intROUND_DOWN
     Rounding mode to round towards zero. Used as a setting to control the rounding mode used during a BigDecimal operation.

All discarded digits are ignored (truncated).

final public static  intROUND_FLOOR
     Rounding mode to round to a more negative number.
final public static  intROUND_HALF_DOWN
     Rounding mode to round to nearest neighbor, where an equidistant value is rounded down. Used as a setting to control the rounding mode used during a BigDecimal operation.

If the discarded digits represent greater than half (0.5 times) the value of a one in the next position then the result should be rounded up (away from zero).

final public static  intROUND_HALF_EVEN
     Rounding mode to round to nearest neighbor, where an equidistant value is rounded to the nearest even neighbor. Used as a setting to control the rounding mode used during a BigDecimal operation.

If the discarded digits represent greater than half (0.5 times) the value of a one in the next position then the result should be rounded up (away from zero).

final public static  intROUND_HALF_UP
     Rounding mode to round to nearest neighbor, where an equidistant value is rounded up. Used as a setting to control the rounding mode used during a BigDecimal operation.

If the discarded digits represent greater than or equal to half (0.5 times) the value of a one in the next position then the result should be rounded up (away from zero).

final public static  intROUND_UNNECESSARY
     Rounding mode to assert that no rounding is necessary.
final public static  intROUND_UP
     Rounding mode to round away from zero.
final public static  intSCIENTIFIC
     Standard floating point notation (with scientific exponential format, where there is one digit before any decimal point).
 intdigits
     The number of digits (precision) to be used for an operation.
 intform
     The form of results from an operation.
 booleanlostDigits
     Controls whether lost digits checking is enabled for an operation.
 introundingMode
     The rounding algorithm to be used for an operation.

Constructor Summary
public  MathContext(int setdigits)
     Constructs a new MathContext with a specified precision.
public  MathContext(int setdigits, int setform)
     Constructs a new MathContext with a specified precision and form.
public  MathContext(int setdigits, int setform, boolean setlostdigits)
     Constructs a new MathContext with a specified precision, form, and lostDigits setting.
public  MathContext(int setdigits, int setform, boolean setlostdigits, int setroundingmode)
     Constructs a new MathContext with a specified precision, form, lostDigits, and roundingMode setting.

Method Summary
public  intgetDigits()
     Returns the digits setting.
public  intgetForm()
     Returns the form setting.
public  booleangetLostDigits()
     Returns the lostDigits setting.
public  intgetRoundingMode()
     Returns the roundingMode setting.
public  java.lang.StringtoString()
     Returns the MathContext as a readable string.

Field Detail
DEFAULT
final public static com.ibm.icu.math.MathContext DEFAULT(Code)
A MathContext object initialized to the default settings for general-purpose arithmetic. That is, digits=9 form=SCIENTIFIC lostDigits=false roundingMode=ROUND_HALF_UP.
See Also:   MathContext.SCIENTIFIC
See Also:   MathContext.ROUND_HALF_UP



ENGINEERING
final public static int ENGINEERING(Code)
Standard floating point notation (with engineering exponential format, where the power of ten is a multiple of 3). Used as a setting to control the form of the result of a BigDecimal operation. A zero result in plain form may have a decimal part of one or more zeros.
See Also:   MathContext.PLAIN
See Also:   MathContext.SCIENTIFIC



PLAIN
final public static int PLAIN(Code)
Plain (fixed point) notation, without any exponent. Used as a setting to control the form of the result of a BigDecimal operation. A zero result in plain form may have a decimal part of one or more zeros.
See Also:   MathContext.ENGINEERING
See Also:   MathContext.SCIENTIFIC



ROUND_CEILING
final public static int ROUND_CEILING(Code)
Rounding mode to round to a more positive number. Used as a setting to control the rounding mode used during a BigDecimal operation.

If any of the discarded digits are non-zero then the result should be rounded towards the next more positive digit.




ROUND_DOWN
final public static int ROUND_DOWN(Code)
Rounding mode to round towards zero. Used as a setting to control the rounding mode used during a BigDecimal operation.

All discarded digits are ignored (truncated). The result is neither incremented nor decremented.




ROUND_FLOOR
final public static int ROUND_FLOOR(Code)
Rounding mode to round to a more negative number. Used as a setting to control the rounding mode used during a BigDecimal operation.

If any of the discarded digits are non-zero then the result should be rounded towards the next more negative digit.




ROUND_HALF_DOWN
final public static int ROUND_HALF_DOWN(Code)
Rounding mode to round to nearest neighbor, where an equidistant value is rounded down. Used as a setting to control the rounding mode used during a BigDecimal operation.

If the discarded digits represent greater than half (0.5 times) the value of a one in the next position then the result should be rounded up (away from zero). Otherwise the discarded digits are ignored.




ROUND_HALF_EVEN
final public static int ROUND_HALF_EVEN(Code)
Rounding mode to round to nearest neighbor, where an equidistant value is rounded to the nearest even neighbor. Used as a setting to control the rounding mode used during a BigDecimal operation.

If the discarded digits represent greater than half (0.5 times) the value of a one in the next position then the result should be rounded up (away from zero). If they represent less than half, then the result should be rounded down.

Otherwise (they represent exactly half) the result is rounded down if its rightmost digit is even, or rounded up if its rightmost digit is odd (to make an even digit).




ROUND_HALF_UP
final public static int ROUND_HALF_UP(Code)
Rounding mode to round to nearest neighbor, where an equidistant value is rounded up. Used as a setting to control the rounding mode used during a BigDecimal operation.

If the discarded digits represent greater than or equal to half (0.5 times) the value of a one in the next position then the result should be rounded up (away from zero). Otherwise the discarded digits are ignored.




ROUND_UNNECESSARY
final public static int ROUND_UNNECESSARY(Code)
Rounding mode to assert that no rounding is necessary. Used as a setting to control the rounding mode used during a BigDecimal operation.

Rounding (potential loss of information) is not permitted. If any of the discarded digits are non-zero then an ArithmeticException should be thrown.




ROUND_UP
final public static int ROUND_UP(Code)
Rounding mode to round away from zero. Used as a setting to control the rounding mode used during a BigDecimal operation.

If any of the discarded digits are non-zero then the result will be rounded up (away from zero).




SCIENTIFIC
final public static int SCIENTIFIC(Code)
Standard floating point notation (with scientific exponential format, where there is one digit before any decimal point). Used as a setting to control the form of the result of a BigDecimal operation. A zero result in plain form may have a decimal part of one or more zeros.
See Also:   MathContext.ENGINEERING
See Also:   MathContext.PLAIN



digits
int digits(Code)
The number of digits (precision) to be used for an operation. A value of 0 indicates that unlimited precision (as many digits as are required) will be used.

The BigDecimal operator methods use this value to determine the precision of results. Note that leading zeros (in the integer part of a number) are never significant.

digits will always be non-negative.




form
int form(Code)
The form of results from an operation.

The BigDecimal operator methods use this value to determine the form of results, in particular whether and how exponential notation should be used.
See Also:   MathContext.ENGINEERING
See Also:   MathContext.PLAIN
See Also:   MathContext.SCIENTIFIC




lostDigits
boolean lostDigits(Code)
Controls whether lost digits checking is enabled for an operation. Set to true to enable checking, or to false to disable checking.

When enabled, the BigDecimal operator methods check the precision of their operand or operands, and throw an ArithmeticException if an operand is more precise than the digits setting (that is, digits would be lost). When disabled, operands are rounded to the specified digits.




roundingMode
int roundingMode(Code)
The rounding algorithm to be used for an operation.

The BigDecimal operator methods use this value to determine the algorithm to be used when non-zero digits have to be discarded in order to reduce the precision of a result. The value must be one of the public constants whose name starts with ROUND_.
See Also:   MathContext.ROUND_CEILING
See Also:   MathContext.ROUND_DOWN
See Also:   MathContext.ROUND_FLOOR
See Also:   MathContext.ROUND_HALF_DOWN
See Also:   MathContext.ROUND_HALF_EVEN
See Also:   MathContext.ROUND_HALF_UP
See Also:   MathContext.ROUND_UNNECESSARY
See Also:   MathContext.ROUND_UP





Constructor Detail
MathContext
public MathContext(int setdigits)(Code)
Constructs a new MathContext with a specified precision. The other settings are set to the default values (see MathContext.DEFAULT ). An IllegalArgumentException is thrown if the setdigits parameter is out of range (<0 or >999999999).
Parameters:
  setdigits - The int digits settingfor this MathContext.
throws:
  IllegalArgumentException - parameter out of range.



MathContext
public MathContext(int setdigits, int setform)(Code)
Constructs a new MathContext with a specified precision and form. The other settings are set to the default values (see MathContext.DEFAULT ). An IllegalArgumentException is thrown if the setdigits parameter is out of range (<0 or >999999999), or if the value given for the setform parameter is not one of the appropriate constants.
Parameters:
  setdigits - The int digits settingfor this MathContext.
Parameters:
  setform - The int form settingfor this MathContext.
throws:
  IllegalArgumentException - parameter out of range.



MathContext
public MathContext(int setdigits, int setform, boolean setlostdigits)(Code)
Constructs a new MathContext with a specified precision, form, and lostDigits setting. The roundingMode setting is set to its default value (see MathContext.DEFAULT ). An IllegalArgumentException is thrown if the setdigits parameter is out of range (<0 or >999999999), or if the value given for the setform parameter is not one of the appropriate constants.
Parameters:
  setdigits - The int digits settingfor this MathContext.
Parameters:
  setform - The int form settingfor this MathContext.
Parameters:
  setlostdigits - The boolean lostDigitssetting for this MathContext.
throws:
  IllegalArgumentException - parameter out of range.



MathContext
public MathContext(int setdigits, int setform, boolean setlostdigits, int setroundingmode)(Code)
Constructs a new MathContext with a specified precision, form, lostDigits, and roundingMode setting. An IllegalArgumentException is thrown if the setdigits parameter is out of range (<0 or >999999999), or if the value given for the setform or setroundingmode parameters is not one of the appropriate constants.
Parameters:
  setdigits - The int digits settingfor this MathContext.
Parameters:
  setform - The int form settingfor this MathContext.
Parameters:
  setlostdigits - The boolean lostDigitssetting for this MathContext.
Parameters:
  setroundingmode - The int roundingMode settingfor this MathContext.
throws:
  IllegalArgumentException - parameter out of range.




Method Detail
getDigits
public int getDigits()(Code)
Returns the digits setting. This value is always non-negative. an int which is the value of the digitssetting



getForm
public int getForm()(Code)
Returns the form setting. This will be one of MathContext.ENGINEERING , MathContext.PLAIN , or MathContext.SCIENTIFIC . an int which is the value of the form setting



getLostDigits
public boolean getLostDigits()(Code)
Returns the lostDigits setting. This will be either true (enabled) or false (disabled). a boolean which is the value of the lostDigitssetting



getRoundingMode
public int getRoundingMode()(Code)
Returns the roundingMode setting. This will be one of MathContext.ROUND_CEILING , MathContext.ROUND_DOWN , MathContext.ROUND_FLOOR , MathContext.ROUND_HALF_DOWN , MathContext.ROUND_HALF_EVEN , MathContext.ROUND_HALF_UP , MathContext.ROUND_UNNECESSARY , or MathContext.ROUND_UP . an int which is the value of the roundingModesetting



toString
public java.lang.String toString()(Code)
Returns the MathContext as a readable string. The String returned represents the settings of the MathContext object as four blank-delimited words separated by a single blank and with no leading or trailing blanks, as follows:
  1. digits=, immediately followed by the value of the digits setting as a numeric word.
  2. form=, immediately followed by the value of the form setting as an uppercase word (one of SCIENTIFIC, PLAIN, or ENGINEERING).
  3. lostDigits=, immediately followed by the value of the lostDigits setting (1 if enabled, 0 if disabled).
  4. roundingMode=, immediately followed by the value of the roundingMode setting as a word. This word will be the same as the name of the corresponding public constant.

For example:
digits=9 form=SCIENTIFIC lostDigits=0 roundingMode=ROUND_HALF_UP

Additional words may be appended to the result of toString in the future if more properties are added to the class. a String representing the context settings.




Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.