Java Doc for Real.java in  » Science » jscience-4.3.1 » org » jscience » mathematics » number » 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 » Science » jscience 4.3.1 » org.jscience.mathematics.number 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.jscience.mathematics.number.Real

Real
final public class Real extends Number implements Field<Real>(Code)

This class represents a real number of arbitrary precision with known/guaranteed uncertainty. A real number consists of a Real.getSignificand significand , a maximum Real.getError error (on the significand value) and a decimal Real.getExponent exponent : ((significand ± error) · 10exponent).

Reals number can be Real.isExact exact (e.g. integer values scaled by a power of ten). Exactness is maintained for org.jscience.mathematics.structure.Ring Ring operations (e.g. addition, multiplication), but typically lost when a multiplicative Real.inverse() inverse is calculated. The minimum precision used for exact numbers is set by Real.setExactPrecision(int) ( javolution.context.LocalContext context local setting, default 19 digits).

The actual Real.getPrecision precision and Real.getAccuracy accuracy of any real number is available and guaranteed (the true/exact value is always within the precision/accuracy range).

Operations on instances of this class are quite fast as information substantially below the precision level (aka noise) is not processed/stored. There is no limit on a real precision but precision degenerates (due to numeric errors) and calculations accelerate as more and more operations are performed.

Instances of this class can be utilized to find approximate solutions to linear equations using the org.jscience.mathematics.vector.Matrix Matrix class for which high-precision reals is often required, the primitive type double being not accurate enough to resolve equations when the matrix's size exceeds 100x100. Furthermore, even for small matrices the "qualified" result is indicative of possible system singularities.


author:
   Jean-Marie Dautelle
version:
   3.3, January 8, 2006
See Also:    * Wikipedia: Real number


Field Summary
final public static  RealNaN
     Holds a Not-a-Number instance (infinite error).
final public static  RealONE
     Holds the exact ONE instance.
final static  XMLFormat<Real>XML
     Holds the default XML representation for real numbers.
final public static  RealZERO
     Holds the exact ZERO instance.


Method Summary
public  Realabs()
     Returns the absolute value of this real number.
public  booleanapproximates(Real that)
     Indicates if this real approximates the one specified.
public  intcompareTo(Real that)
     Compares two real numbers numerically.
Parameters:
  that - the real to compare with.
public  Realcopy()
    
public  Realdivide(long divisor)
     Returns this real number divided by the specified int divisor.
public  Realdivide(Real that)
     Returns this real number divided by the one specified.
Parameters:
  that - the real divisor.
public  doubledoubleValue()
     Returns the value of this real number as a double.
public  booleanequals(Object that)
     Compares this real number against the specified object.

Note: This method returns true if this or that Real.isNaN is Not-A-Number , even though Double.NaN == Double.NaN has the value false.


Parameters:
  that - the object to compare with.
public  intgetAccuracy()
     Returns the number of decimal digits guaranteed exact which appear to the right of the decimal point (absolute error).
public  intgetError()
     Returns the maximum error (positive) on this real significand.
public static  intgetExactPrecision()
     Returns the javolution.context.LocalContext local minimum precision (number of exact digits) when exact numbers have to be approximated.
public  intgetExponent()
     Returns the exponent of the power of 10 multiplier.
final public  intgetPrecision()
     Returns the total number of decimal digits guaranteed exact (relative error).
public  LargeIntegergetSignificand()
     Returns this real significand value.
public  inthashCode()
     Returns the hash code for this real number.
public  Realinverse()
     Returns the reciprocal (or inverse) of this real number.
public  booleanisExact()
     Indicates if this real number is exact ( Real.getError() error == 0).
public  booleanisLargerThan(Real that)
     Compares the absolute value of two real numbers.
Parameters:
  that - the real number to be compared with.
public  booleanisNaN()
     Indicates if this real is Not-a-Number (unbounded value interval).
public  booleanisNegative()
     Indicates if this real is less than zero.
public  booleanisPositive()
     Indicates if this real is greater than zero.
public  longlongValue()
     Returns the value of this real number as a long.
public  Realminus(Real that)
     Returns the difference between this real number and the one specified.
Parameters:
  that - the real to be subtracted.
public  Realopposite()
     Returns the negation of this real number.
public  Realplus(Real that)
     Returns the sum of this real number with the one specified.
Parameters:
  that - the real to be added.
public  LargeIntegerround()
     Returns the closest integer value to this rational number.
public static  voidsetExactPrecision(int precision)
     Sets the javolution.context.LocalContext local minimum precision (number of exact digits) when exact numbers have to be approximated.
public  Realsqrt()
     Returns the square root of this real number, the more accurate is this real number, the more accurate the square root.
public  Realtimes(long multiplier)
     Returns the product of this real number with the specified long multiplier.
Parameters:
  multiplier - the long multiplier.
public  Realtimes(Real that)
     Returns the product of this real number with the one specified.
Parameters:
  that - the real multiplier.
public  TexttoText()
     Returns the decimal text representation of this number.
public static  RealvalueOf(LargeInteger significand, int error, int exponent)
     Returns a real having the specified significand, error and exponent values. If the error is 0, the real is assumed exact.
public static  RealvalueOf(double doubleValue)
     Returns the real number (inexact except for 0.0) corresponding to the specified double value.
public static  RealvalueOf(long longValue)
     Returns the exact real number corresponding to the specified long value (convenience method).
public static  RealvalueOf(CharSequence chars)
     Returns the real for the specified character sequence. If the precision is not specified (using the ± symbol), the real is supposed exact.

Field Detail
NaN
final public static Real NaN(Code)
Holds a Not-a-Number instance (infinite error).



ONE
final public static Real ONE(Code)
Holds the exact ONE instance.



XML
final static XMLFormat<Real> XML(Code)
Holds the default XML representation for real numbers. This representation consists of a simple value attribute holding the Real.toText() textual representation.



ZERO
final public static Real ZERO(Code)
Holds the exact ZERO instance.





Method Detail
abs
public Real abs()(Code)
Returns the absolute value of this real number. |this|.



approximates
public boolean approximates(Real that)(Code)
Indicates if this real approximates the one specified. This method takes into account possible errors (e.g. numeric errors) to make this determination.

Note: This method returns true if this or that Real.isNaN (basically Not-A-Number approximates anything).


Parameters:
  that - the real to compare with. this ≈ that



compareTo
public int compareTo(Real that)(Code)
Compares two real numbers numerically.
Parameters:
  that - the real to compare with. -1, 0 or 1 as this real is numerically less than, equal to,or greater than that.
throws:
  ClassCastException - that is not a Real.



copy
public Real copy()(Code)



divide
public Real divide(long divisor)(Code)
Returns this real number divided by the specified int divisor.
Parameters:
  divisor - the int divisor. this / divisor



divide
public Real divide(Real that)(Code)
Returns this real number divided by the one specified.
Parameters:
  that - the real divisor. this / that.
throws:
  ArithmeticException - if that.equals(ZERO)



doubleValue
public double doubleValue()(Code)
Returns the value of this real number as a double. the numeric value represented by this real after conversionto type double.



equals
public boolean equals(Object that)(Code)
Compares this real number against the specified object.

Note: This method returns true if this or that Real.isNaN is Not-A-Number , even though Double.NaN == Double.NaN has the value false.


Parameters:
  that - the object to compare with. true if the objects are two reals with same significand, error and exponent;false otherwise.



getAccuracy
public int getAccuracy()(Code)
Returns the number of decimal digits guaranteed exact which appear to the right of the decimal point (absolute error). a measure of the absolute error of this real number.



getError
public int getError()(Code)
Returns the maximum error (positive) on this real significand. the maximum error on the significand.



getExactPrecision
public static int getExactPrecision()(Code)
Returns the javolution.context.LocalContext local minimum precision (number of exact digits) when exact numbers have to be approximated. the minimum number of digits assumed exact for Real.isExact exact real numbers.



getExponent
public int getExponent()(Code)
Returns the exponent of the power of 10 multiplier. the decimal exponent.



getPrecision
final public int getPrecision()(Code)
Returns the total number of decimal digits guaranteed exact (relative error). a measure of the relative error of this real number.



getSignificand
public LargeInteger getSignificand()(Code)
Returns this real significand value. the significand.



hashCode
public int hashCode()(Code)
Returns the hash code for this real number. the hash code value.



inverse
public Real inverse()(Code)
Returns the reciprocal (or inverse) of this real number. 1 / this.



isExact
public boolean isExact()(Code)
Indicates if this real number is exact ( Real.getError() error == 0). getError() == 0



isLargerThan
public boolean isLargerThan(Real that)(Code)
Compares the absolute value of two real numbers.
Parameters:
  that - the real number to be compared with. |this| > |that|



isNaN
public boolean isNaN()(Code)
Indicates if this real is Not-a-Number (unbounded value interval). true if this number has unbounded value interval;false otherwise.



isNegative
public boolean isNegative()(Code)
Indicates if this real is less than zero. this < 0



isPositive
public boolean isPositive()(Code)
Indicates if this real is greater than zero. this > 0



longValue
public long longValue()(Code)
Returns the value of this real number as a long. the numeric value represented by this real after conversionto type long.



minus
public Real minus(Real that)(Code)
Returns the difference between this real number and the one specified.
Parameters:
  that - the real to be subtracted. this - that.



opposite
public Real opposite()(Code)
Returns the negation of this real number. -this.



plus
public Real plus(Real that)(Code)
Returns the sum of this real number with the one specified.
Parameters:
  that - the real to be added. this + that.



round
public LargeInteger round()(Code)
Returns the closest integer value to this rational number. this real rounded to the nearest integer.
throws:
  ArithmeticException - if this.isNaN()



setExactPrecision
public static void setExactPrecision(int precision)(Code)
Sets the javolution.context.LocalContext local minimum precision (number of exact digits) when exact numbers have to be approximated.
Parameters:
  precision - the minimum number of digits assumed exact for Real.isExact exact numbers.



sqrt
public Real sqrt()(Code)
Returns the square root of this real number, the more accurate is this real number, the more accurate the square root. the positive square root of this real number.



times
public Real times(long multiplier)(Code)
Returns the product of this real number with the specified long multiplier.
Parameters:
  multiplier - the long multiplier. this · multiplier.



times
public Real times(Real that)(Code)
Returns the product of this real number with the one specified.
Parameters:
  that - the real multiplier. this · that.



toText
public Text toText()(Code)
Returns the decimal text representation of this number. the text representation of this number.



valueOf
public static Real valueOf(LargeInteger significand, int error, int exponent)(Code)
Returns a real having the specified significand, error and exponent values. If the error is 0, the real is assumed exact. For example:[code] // x = 0.0 ± 0.01 Real x = Real.valueOf(LargeInteger.ZERO, 1, -2); // y = -12.3 exact Real y = Real.valueOf(LargeInteger.valueOf(-123), 0, -1); [/code]
Parameters:
  significand - this real significand.
Parameters:
  error - the maximum error on the significand.
Parameters:
  exponent - the decimal exponent. (significand ± error)·10exponent)
throws:
  IllegalArgumentException - if error < 0



valueOf
public static Real valueOf(double doubleValue)(Code)
Returns the real number (inexact except for 0.0) corresponding to the specified double value. The error is derived from the inexact representation of double values intrinsic to the 64 bits IEEE 754 format.
Parameters:
  doubleValue - the double value to convert. the corresponding real number.



valueOf
public static Real valueOf(long longValue)(Code)
Returns the exact real number corresponding to the specified long value (convenience method).
Parameters:
  longValue - the exact long value. Real.valueOf(LargeInteger.valueOf(longValue), 0, 0)



valueOf
public static Real valueOf(CharSequence chars) throws NumberFormatException(Code)
Returns the real for the specified character sequence. If the precision is not specified (using the ± symbol), the real is supposed exact. Example of valid character sequences:
  • "1.2E3" (1200 exact)
  • "1.2E3±1E-2" (1200 ± 0.01)

  • Parameters:
      chars - the character sequence. the corresponding real number.
    throws:
      NumberFormatException - if the character sequence does not containa parsable real.



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