Java Doc for Fraction.java in  » Science » Apache-commons-math-1.1 » org » apache » commons » math » fraction » 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 » Apache commons math 1.1 » org.apache.commons.math.fraction 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.lang.Number
      org.apache.commons.math.fraction.Fraction

Fraction
public class Fraction extends Number implements Comparable(Code)
Representation of a rational number.
since:
   1.1
version:
   $Revision: 348519 $ $Date: 2005-11-23 12:12:18 -0700 (Wed, 23 Nov 2005) $


Field Summary
final public static  FractionONE
     A fraction representing "1 / 1".
final public static  FractionZERO
     A fraction representing "0 / 1".

Constructor Summary
public  Fraction(double value)
     Create a fraction given the double value.
public  Fraction(double value, double epsilon, int maxIterations)
     Create a fraction given the double value.

References:


Parameters:
  value - the double value to convert to a fraction.
Parameters:
  epsilon - maximum error allowed.
public  Fraction(int num, int den)
     Create a fraction given the numerator and denominator.

Method Summary
public  Fractionabs()
     Returns the absolute value of this fraction.
public  Fractionadd(Fraction fraction)
    

Adds the value of this fraction to another, returning the result in reduced form.

public  intcompareTo(Object object)
     Compares this object to another based on size.
public  Fractiondivide(Fraction fraction)
    
public  doubledoubleValue()
     Gets the fraction as a double.
public  booleanequals(Object other)
     Test for the equality of two fractions.
public  floatfloatValue()
     Gets the fraction as a float.
public  intgetDenominator()
     Access the denominator.
public  intgetNumerator()
     Access the numerator.
public static  FractiongetReducedFraction(int numerator, int denominator)
    
public  inthashCode()
     Gets a hashCode for the fraction.
public  intintValue()
     Gets the fraction as an int.
public  longlongValue()
     Gets the fraction as a long.
public  Fractionmultiply(Fraction fraction)
    
public  Fractionnegate()
     Return the additive inverse of this fraction.
public  Fractionreciprocal()
     Return the multiplicative inverse of this fraction.
public  Fractionsubtract(Fraction fraction)
    

Field Detail
ONE
final public static Fraction ONE(Code)
A fraction representing "1 / 1".



ZERO
final public static Fraction ZERO(Code)
A fraction representing "0 / 1".




Constructor Detail
Fraction
public Fraction(double value) throws ConvergenceException(Code)
Create a fraction given the double value.
Parameters:
  value - the double value to convert to a fraction.
throws:
  ConvergenceException - if the continued fraction failed toconverge.



Fraction
public Fraction(double value, double epsilon, int maxIterations) throws ConvergenceException(Code)
Create a fraction given the double value.

References:


Parameters:
  value - the double value to convert to a fraction.
Parameters:
  epsilon - maximum error allowed. The resulting fraction is withinepsilon of value, in absolute terms.
Parameters:
  maxIterations - maximum number of convergents
throws:
  ConvergenceException - if the continued fraction failed toconverge.



Fraction
public Fraction(int num, int den)(Code)
Create a fraction given the numerator and denominator. The fraction is reduced to lowest terms.
Parameters:
  num - the numerator.
Parameters:
  den - the denominator.
throws:
  ArithmeticException - if the denomiator is zero




Method Detail
abs
public Fraction abs()(Code)
Returns the absolute value of this fraction. the absolute value.



add
public Fraction add(Fraction fraction)(Code)

Adds the value of this fraction to another, returning the result in reduced form. The algorithm follows Knuth, 4.5.1.


Parameters:
  fraction - the fraction to add, must not be null a Fraction instance with the resulting values
throws:
  IllegalArgumentException - if the fraction is null
throws:
  ArithmeticException - if the resulting numerator or denominator exceedsInteger.MAX_VALUE



compareTo
public int compareTo(Object object)(Code)
Compares this object to another based on size.
Parameters:
  object - the object to compare to -1 if this is less than object, +1 if this is greaterthan object, 0 if they are equal.



divide
public Fraction divide(Fraction fraction)(Code)

Divide the value of this fraction by another.


Parameters:
  fraction - the fraction to divide by, must not be null a Fraction instance with the resulting values
throws:
  IllegalArgumentException - if the fraction is null
throws:
  ArithmeticException - if the fraction to divide by is zero
throws:
  ArithmeticException - if the resulting numerator or denominator exceedsInteger.MAX_VALUE



doubleValue
public double doubleValue()(Code)
Gets the fraction as a double. This calculates the fraction as the numerator divided by denominator. the fraction as a double



equals
public boolean equals(Object other)(Code)
Test for the equality of two fractions. If the lowest term numerator and denominators are the same for both fractions, the two fractions are considered to be equal.
Parameters:
  other - fraction to test for equality to this fraction true if two fractions are equal, false if object isnull, not an instance of Fraction, or not equalto this fraction instance.



floatValue
public float floatValue()(Code)
Gets the fraction as a float. This calculates the fraction as the numerator divided by denominator. the fraction as a float



getDenominator
public int getDenominator()(Code)
Access the denominator. the denominator.



getNumerator
public int getNumerator()(Code)
Access the numerator. the numerator.



getReducedFraction
public static Fraction getReducedFraction(int numerator, int denominator)(Code)

Creates a Fraction instance with the 2 parts of a fraction Y/Z.

Any negative signs are resolved to be on the numerator.


Parameters:
  numerator - the numerator, for example the three in 'three sevenths'
Parameters:
  denominator - the denominator, for example the seven in 'three sevenths' a new fraction instance, with the numerator and denominator reduced
throws:
  ArithmeticException - if the denominator is zero



hashCode
public int hashCode()(Code)
Gets a hashCode for the fraction. a hash code value for this object



intValue
public int intValue()(Code)
Gets the fraction as an int. This returns the whole number part of the fraction. the whole number fraction part



longValue
public long longValue()(Code)
Gets the fraction as a long. This returns the whole number part of the fraction. the whole number fraction part



multiply
public Fraction multiply(Fraction fraction)(Code)

Multiplies the value of this fraction by another, returning the result in reduced form.


Parameters:
  fraction - the fraction to multiply by, must not be null a Fraction instance with the resulting values
throws:
  IllegalArgumentException - if the fraction is null
throws:
  ArithmeticException - if the resulting numerator or denominator exceedsInteger.MAX_VALUE



negate
public Fraction negate()(Code)
Return the additive inverse of this fraction. the negation of this fraction.



reciprocal
public Fraction reciprocal()(Code)
Return the multiplicative inverse of this fraction. the reciprocal fraction



subtract
public Fraction subtract(Fraction fraction)(Code)

Subtracts the value of another fraction from the value of this one, returning the result in reduced form.


Parameters:
  fraction - the fraction to subtract, must not be null a Fraction instance with the resulting values
throws:
  IllegalArgumentException - if the fraction is null
throws:
  ArithmeticException - if the resulting numerator or denominatorcannot be represented in an int.



Methods inherited from java.lang.Number
public byte byteValue()(Code)(Java Doc)
abstract public double doubleValue()(Code)(Java Doc)
abstract public float floatValue()(Code)(Java Doc)
abstract public int intValue()(Code)(Java Doc)
abstract public long longValue()(Code)(Java Doc)
public short shortValue()(Code)(Java Doc)

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.