blob: 19190c04243ce3ba168bb3c74a41b851b8f7891d [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
<title>Fraction (Apache Commons Math 3.3 API)</title>
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Fraction (Apache Commons Math 3.3 API)";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/Fraction.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><em><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script></em></div>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/commons/math3/fraction/BigFractionFormat.html" title="class in org.apache.commons.math3.fraction"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../org/apache/commons/math3/fraction/FractionConversionException.html" title="class in org.apache.commons.math3.fraction"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/commons/math3/fraction/Fraction.html" target="_top">Frames</a></li>
<li><a href="Fraction.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field_summary">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field_detail">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.commons.math3.fraction</div>
<h2 title="Class Fraction" class="title">Class Fraction</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Number.html?is-external=true" title="class or interface in java.lang">java.lang.Number</a></li>
<li>
<ul class="inheritance">
<li>org.apache.commons.math3.fraction.Fraction</li>
</ul>
</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Implemented Interfaces:</dt>
<dd><a href="http://docs.oracle.com/javase/6/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Comparable.html?is-external=true" title="class or interface in java.lang">Comparable</a>&lt;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&gt;, <a href="../../../../../org/apache/commons/math3/FieldElement.html" title="interface in org.apache.commons.math3">FieldElement</a>&lt;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&gt;</dd>
</dl>
<hr>
<br>
<pre>public class <span class="strong">Fraction</span>
extends <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Number.html?is-external=true" title="class or interface in java.lang">Number</a>
implements <a href="../../../../../org/apache/commons/math3/FieldElement.html" title="interface in org.apache.commons.math3">FieldElement</a>&lt;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&gt;, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Comparable.html?is-external=true" title="class or interface in java.lang">Comparable</a>&lt;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&gt;, <a href="http://docs.oracle.com/javase/6/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a></pre>
<div class="block">Representation of a rational number.
implements Serializable since 2.0</div>
<dl><dt><span class="strong">Since:</span></dt>
<dd>1.1</dd>
<dt><span class="strong">Version:</span></dt>
<dd>$Id: Fraction.java 1519204 2013-08-31 19:43:02Z tn $</dd>
<dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../serialized-form.html#org.apache.commons.math3.fraction.Fraction">Serialized Form</a></dd></dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== FIELD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="field_summary">
<!-- -->
</a>
<h3>Field Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation">
<caption><span>Fields</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Field and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#FOUR_FIFTHS">FOUR_FIFTHS</a></strong></code>
<div class="block">A fraction representing "4/5".</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#MINUS_ONE">MINUS_ONE</a></strong></code>
<div class="block">A fraction representing "-1 / 1".</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#ONE">ONE</a></strong></code>
<div class="block">A fraction representing "1".</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#ONE_FIFTH">ONE_FIFTH</a></strong></code>
<div class="block">A fraction representing "1/5".</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#ONE_HALF">ONE_HALF</a></strong></code>
<div class="block">A fraction representing "1/2".</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#ONE_QUARTER">ONE_QUARTER</a></strong></code>
<div class="block">A fraction representing "1/4".</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#ONE_THIRD">ONE_THIRD</a></strong></code>
<div class="block">A fraction representing "1/3".</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#THREE_FIFTHS">THREE_FIFTHS</a></strong></code>
<div class="block">A fraction representing "3/5".</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#THREE_QUARTERS">THREE_QUARTERS</a></strong></code>
<div class="block">A fraction representing "3/4".</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#TWO">TWO</a></strong></code>
<div class="block">A fraction representing "2 / 1".</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#TWO_FIFTHS">TWO_FIFTHS</a></strong></code>
<div class="block">A fraction representing "2/5".</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#TWO_QUARTERS">TWO_QUARTERS</a></strong></code>
<div class="block">A fraction representing "2/4".</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#TWO_THIRDS">TWO_THIRDS</a></strong></code>
<div class="block">A fraction representing "2/3".</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#ZERO">ZERO</a></strong></code>
<div class="block">A fraction representing "0".</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#Fraction(double)">Fraction</a></strong>(double&nbsp;value)</code>
<div class="block">Create a fraction given the double value.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colOne"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#Fraction(double, double, int)">Fraction</a></strong>(double&nbsp;value,
double&nbsp;epsilon,
int&nbsp;maxIterations)</code>
<div class="block">Create a fraction given the double value and maximum error allowed.</div>
</td>
</tr>
<tr class="altColor">
<td class="colOne"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#Fraction(double, int)">Fraction</a></strong>(double&nbsp;value,
int&nbsp;maxDenominator)</code>
<div class="block">Create a fraction given the double value and maximum denominator.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colOne"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#Fraction(int)">Fraction</a></strong>(int&nbsp;num)</code>
<div class="block">Create a fraction from an int.</div>
</td>
</tr>
<tr class="altColor">
<td class="colOne"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#Fraction(int, int)">Fraction</a></strong>(int&nbsp;num,
int&nbsp;den)</code>
<div class="block">Create a fraction given the numerator and denominator.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#abs()">abs</a></strong>()</code>
<div class="block">Returns the absolute value of this fraction.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#add(org.apache.commons.math3.fraction.Fraction)">add</a></strong>(<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;fraction)</code>
<div class="block">Adds the value of this fraction to another, returning the result in reduced form.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#add(int)">add</a></strong>(int&nbsp;i)</code>
<div class="block">Add an integer to the fraction.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#compareTo(org.apache.commons.math3.fraction.Fraction)">compareTo</a></strong>(<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;object)</code>
<div class="block">Compares this object to another based on size.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#divide(org.apache.commons.math3.fraction.Fraction)">divide</a></strong>(<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;fraction)</code>
<div class="block">Divide the value of this fraction by another.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#divide(int)">divide</a></strong>(int&nbsp;i)</code>
<div class="block">Divide the fraction by an integer.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#doubleValue()">doubleValue</a></strong>()</code>
<div class="block">Gets the fraction as a <tt>double</tt>.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#equals(java.lang.Object)">equals</a></strong>(<a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&nbsp;other)</code>
<div class="block">Test for the equality of two fractions.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>float</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#floatValue()">floatValue</a></strong>()</code>
<div class="block">Gets the fraction as a <tt>float</tt>.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#getDenominator()">getDenominator</a></strong>()</code>
<div class="block">Access the denominator.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/commons/math3/fraction/FractionField.html" title="class in org.apache.commons.math3.fraction">FractionField</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#getField()">getField</a></strong>()</code>
<div class="block">Get the <a href="../../../../../org/apache/commons/math3/Field.html" title="interface in org.apache.commons.math3"><code>Field</code></a> to which the instance belongs.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#getNumerator()">getNumerator</a></strong>()</code>
<div class="block">Access the numerator.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#getReducedFraction(int, int)">getReducedFraction</a></strong>(int&nbsp;numerator,
int&nbsp;denominator)</code>
<div class="block">Creates a <code>Fraction</code> instance with the 2 parts
of a fraction Y/Z.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#hashCode()">hashCode</a></strong>()</code>
<div class="block">Gets a hashCode for the fraction.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#intValue()">intValue</a></strong>()</code>
<div class="block">Gets the fraction as an <tt>int</tt>.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>long</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#longValue()">longValue</a></strong>()</code>
<div class="block">Gets the fraction as a <tt>long</tt>.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#multiply(org.apache.commons.math3.fraction.Fraction)">multiply</a></strong>(<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;fraction)</code>
<div class="block">Multiplies the value of this fraction by another, returning the
result in reduced form.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#multiply(int)">multiply</a></strong>(int&nbsp;i)</code>
<div class="block">Multiply the fraction by an integer.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#negate()">negate</a></strong>()</code>
<div class="block">Return the additive inverse of this fraction.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#percentageValue()">percentageValue</a></strong>()</code>
<div class="block">
Gets the fraction percentage as a <tt>double</tt>.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#reciprocal()">reciprocal</a></strong>()</code>
<div class="block">Return the multiplicative inverse of this fraction.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#subtract(org.apache.commons.math3.fraction.Fraction)">subtract</a></strong>(<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;fraction)</code>
<div class="block">Subtracts the value of another fraction from the value of this one,
returning the result in reduced form.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#subtract(int)">subtract</a></strong>(int&nbsp;i)</code>
<div class="block">Subtract an integer from the fraction.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/fraction/Fraction.html#toString()">toString</a></strong>()</code>
<div class="block">
Returns the <code>String</code> representing this fraction, ie
"num / dem" or just "num" if the denominator is one.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Number">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.<a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Number.html?is-external=true" title="class or interface in java.lang">Number</a></h3>
<code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Number.html?is-external=true#byteValue()" title="class or interface in java.lang">byteValue</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Number.html?is-external=true#shortValue()" title="class or interface in java.lang">shortValue</a></code></li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.<a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3>
<code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ FIELD DETAIL =========== -->
<ul class="blockList">
<li class="blockList"><a name="field_detail">
<!-- -->
</a>
<h3>Field Detail</h3>
<a name="TWO">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>TWO</h4>
<pre>public static final&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a> TWO</pre>
<div class="block">A fraction representing "2 / 1".</div>
</li>
</ul>
<a name="ONE">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>ONE</h4>
<pre>public static final&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a> ONE</pre>
<div class="block">A fraction representing "1".</div>
</li>
</ul>
<a name="ZERO">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>ZERO</h4>
<pre>public static final&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a> ZERO</pre>
<div class="block">A fraction representing "0".</div>
</li>
</ul>
<a name="FOUR_FIFTHS">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>FOUR_FIFTHS</h4>
<pre>public static final&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a> FOUR_FIFTHS</pre>
<div class="block">A fraction representing "4/5".</div>
</li>
</ul>
<a name="ONE_FIFTH">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>ONE_FIFTH</h4>
<pre>public static final&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a> ONE_FIFTH</pre>
<div class="block">A fraction representing "1/5".</div>
</li>
</ul>
<a name="ONE_HALF">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>ONE_HALF</h4>
<pre>public static final&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a> ONE_HALF</pre>
<div class="block">A fraction representing "1/2".</div>
</li>
</ul>
<a name="ONE_QUARTER">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>ONE_QUARTER</h4>
<pre>public static final&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a> ONE_QUARTER</pre>
<div class="block">A fraction representing "1/4".</div>
</li>
</ul>
<a name="ONE_THIRD">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>ONE_THIRD</h4>
<pre>public static final&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a> ONE_THIRD</pre>
<div class="block">A fraction representing "1/3".</div>
</li>
</ul>
<a name="THREE_FIFTHS">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>THREE_FIFTHS</h4>
<pre>public static final&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a> THREE_FIFTHS</pre>
<div class="block">A fraction representing "3/5".</div>
</li>
</ul>
<a name="THREE_QUARTERS">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>THREE_QUARTERS</h4>
<pre>public static final&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a> THREE_QUARTERS</pre>
<div class="block">A fraction representing "3/4".</div>
</li>
</ul>
<a name="TWO_FIFTHS">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>TWO_FIFTHS</h4>
<pre>public static final&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a> TWO_FIFTHS</pre>
<div class="block">A fraction representing "2/5".</div>
</li>
</ul>
<a name="TWO_QUARTERS">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>TWO_QUARTERS</h4>
<pre>public static final&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a> TWO_QUARTERS</pre>
<div class="block">A fraction representing "2/4".</div>
</li>
</ul>
<a name="TWO_THIRDS">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>TWO_THIRDS</h4>
<pre>public static final&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a> TWO_THIRDS</pre>
<div class="block">A fraction representing "2/3".</div>
</li>
</ul>
<a name="MINUS_ONE">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>MINUS_ONE</h4>
<pre>public static final&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a> MINUS_ONE</pre>
<div class="block">A fraction representing "-1 / 1".</div>
</li>
</ul>
</li>
</ul>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a name="Fraction(double)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>Fraction</h4>
<pre>public&nbsp;Fraction(double&nbsp;value)
throws <a href="../../../../../org/apache/commons/math3/fraction/FractionConversionException.html" title="class in org.apache.commons.math3.fraction">FractionConversionException</a></pre>
<div class="block">Create a fraction given the double value.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>value</code> - the double value to convert to a fraction.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/fraction/FractionConversionException.html" title="class in org.apache.commons.math3.fraction">FractionConversionException</a></code> - if the continued fraction failed to
converge.</dd></dl>
</li>
</ul>
<a name="Fraction(double, double, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>Fraction</h4>
<pre>public&nbsp;Fraction(double&nbsp;value,
double&nbsp;epsilon,
int&nbsp;maxIterations)
throws <a href="../../../../../org/apache/commons/math3/fraction/FractionConversionException.html" title="class in org.apache.commons.math3.fraction">FractionConversionException</a></pre>
<div class="block">Create a fraction given the double value and maximum error allowed.
<p>
References:
<ul>
<li><a href="http://mathworld.wolfram.com/ContinuedFraction.html">
Continued Fraction</a> equations (11) and (22)-(26)</li>
</ul>
</p></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>value</code> - the double value to convert to a fraction.</dd><dd><code>epsilon</code> - maximum error allowed. The resulting fraction is within
<code>epsilon</code> of <code>value</code>, in absolute terms.</dd><dd><code>maxIterations</code> - maximum number of convergents</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/fraction/FractionConversionException.html" title="class in org.apache.commons.math3.fraction">FractionConversionException</a></code> - if the continued fraction failed to
converge.</dd></dl>
</li>
</ul>
<a name="Fraction(double, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>Fraction</h4>
<pre>public&nbsp;Fraction(double&nbsp;value,
int&nbsp;maxDenominator)
throws <a href="../../../../../org/apache/commons/math3/fraction/FractionConversionException.html" title="class in org.apache.commons.math3.fraction">FractionConversionException</a></pre>
<div class="block">Create a fraction given the double value and maximum denominator.
<p>
References:
<ul>
<li><a href="http://mathworld.wolfram.com/ContinuedFraction.html">
Continued Fraction</a> equations (11) and (22)-(26)</li>
</ul>
</p></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>value</code> - the double value to convert to a fraction.</dd><dd><code>maxDenominator</code> - The maximum allowed value for denominator</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/fraction/FractionConversionException.html" title="class in org.apache.commons.math3.fraction">FractionConversionException</a></code> - if the continued fraction failed to
converge</dd></dl>
</li>
</ul>
<a name="Fraction(int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>Fraction</h4>
<pre>public&nbsp;Fraction(int&nbsp;num)</pre>
<div class="block">Create a fraction from an int.
The fraction is num / 1.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>num</code> - the numerator.</dd></dl>
</li>
</ul>
<a name="Fraction(int, int)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>Fraction</h4>
<pre>public&nbsp;Fraction(int&nbsp;num,
int&nbsp;den)</pre>
<div class="block">Create a fraction given the numerator and denominator. The fraction is
reduced to lowest terms.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>num</code> - the numerator.</dd><dd><code>den</code> - the denominator.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the denominator is <code>zero</code></dd></dl>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="abs()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>abs</h4>
<pre>public&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;abs()</pre>
<div class="block">Returns the absolute value of this fraction.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>the absolute value.</dd></dl>
</li>
</ul>
<a name="compareTo(org.apache.commons.math3.fraction.Fraction)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>compareTo</h4>
<pre>public&nbsp;int&nbsp;compareTo(<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;object)</pre>
<div class="block">Compares this object to another based on size.</div>
<dl>
<dt><strong>Specified by:</strong></dt>
<dd><code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Comparable.html?is-external=true#compareTo(T)" title="class or interface in java.lang">compareTo</a></code>&nbsp;in interface&nbsp;<code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Comparable.html?is-external=true" title="class or interface in java.lang">Comparable</a>&lt;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&gt;</code></dd>
<dt><span class="strong">Parameters:</span></dt><dd><code>object</code> - the object to compare to</dd>
<dt><span class="strong">Returns:</span></dt><dd>-1 if this is less than <tt>object</tt>, +1 if this is greater
than <tt>object</tt>, 0 if they are equal.</dd></dl>
</li>
</ul>
<a name="doubleValue()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>doubleValue</h4>
<pre>public&nbsp;double&nbsp;doubleValue()</pre>
<div class="block">Gets the fraction as a <tt>double</tt>. This calculates the fraction as
the numerator divided by denominator.</div>
<dl>
<dt><strong>Specified by:</strong></dt>
<dd><code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Number.html?is-external=true#doubleValue()" title="class or interface in java.lang">doubleValue</a></code>&nbsp;in class&nbsp;<code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Number.html?is-external=true" title="class or interface in java.lang">Number</a></code></dd>
<dt><span class="strong">Returns:</span></dt><dd>the fraction as a <tt>double</tt></dd></dl>
</li>
</ul>
<a name="equals(java.lang.Object)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equals</h4>
<pre>public&nbsp;boolean&nbsp;equals(<a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&nbsp;other)</pre>
<div class="block">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.</div>
<dl>
<dt><strong>Overrides:</strong></dt>
<dd><code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</a></code>&nbsp;in class&nbsp;<code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></code></dd>
<dt><span class="strong">Parameters:</span></dt><dd><code>other</code> - fraction to test for equality to this fraction</dd>
<dt><span class="strong">Returns:</span></dt><dd>true if two fractions are equal, false if object is
<tt>null</tt>, not an instance of <a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction"><code>Fraction</code></a>, or not equal
to this fraction instance.</dd></dl>
</li>
</ul>
<a name="floatValue()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>floatValue</h4>
<pre>public&nbsp;float&nbsp;floatValue()</pre>
<div class="block">Gets the fraction as a <tt>float</tt>. This calculates the fraction as
the numerator divided by denominator.</div>
<dl>
<dt><strong>Specified by:</strong></dt>
<dd><code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Number.html?is-external=true#floatValue()" title="class or interface in java.lang">floatValue</a></code>&nbsp;in class&nbsp;<code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Number.html?is-external=true" title="class or interface in java.lang">Number</a></code></dd>
<dt><span class="strong">Returns:</span></dt><dd>the fraction as a <tt>float</tt></dd></dl>
</li>
</ul>
<a name="getDenominator()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getDenominator</h4>
<pre>public&nbsp;int&nbsp;getDenominator()</pre>
<div class="block">Access the denominator.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>the denominator.</dd></dl>
</li>
</ul>
<a name="getNumerator()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getNumerator</h4>
<pre>public&nbsp;int&nbsp;getNumerator()</pre>
<div class="block">Access the numerator.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>the numerator.</dd></dl>
</li>
</ul>
<a name="hashCode()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hashCode</h4>
<pre>public&nbsp;int&nbsp;hashCode()</pre>
<div class="block">Gets a hashCode for the fraction.</div>
<dl>
<dt><strong>Overrides:</strong></dt>
<dd><code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</a></code>&nbsp;in class&nbsp;<code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></code></dd>
<dt><span class="strong">Returns:</span></dt><dd>a hash code value for this object</dd></dl>
</li>
</ul>
<a name="intValue()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>intValue</h4>
<pre>public&nbsp;int&nbsp;intValue()</pre>
<div class="block">Gets the fraction as an <tt>int</tt>. This returns the whole number part
of the fraction.</div>
<dl>
<dt><strong>Specified by:</strong></dt>
<dd><code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Number.html?is-external=true#intValue()" title="class or interface in java.lang">intValue</a></code>&nbsp;in class&nbsp;<code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Number.html?is-external=true" title="class or interface in java.lang">Number</a></code></dd>
<dt><span class="strong">Returns:</span></dt><dd>the whole number fraction part</dd></dl>
</li>
</ul>
<a name="longValue()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>longValue</h4>
<pre>public&nbsp;long&nbsp;longValue()</pre>
<div class="block">Gets the fraction as a <tt>long</tt>. This returns the whole number part
of the fraction.</div>
<dl>
<dt><strong>Specified by:</strong></dt>
<dd><code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Number.html?is-external=true#longValue()" title="class or interface in java.lang">longValue</a></code>&nbsp;in class&nbsp;<code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Number.html?is-external=true" title="class or interface in java.lang">Number</a></code></dd>
<dt><span class="strong">Returns:</span></dt><dd>the whole number fraction part</dd></dl>
</li>
</ul>
<a name="negate()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>negate</h4>
<pre>public&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;negate()</pre>
<div class="block">Return the additive inverse of this fraction.</div>
<dl>
<dt><strong>Specified by:</strong></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/FieldElement.html#negate()">negate</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../org/apache/commons/math3/FieldElement.html" title="interface in org.apache.commons.math3">FieldElement</a>&lt;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&gt;</code></dd>
<dt><span class="strong">Returns:</span></dt><dd>the negation of this fraction.</dd></dl>
</li>
</ul>
<a name="reciprocal()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>reciprocal</h4>
<pre>public&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;reciprocal()</pre>
<div class="block">Return the multiplicative inverse of this fraction.</div>
<dl>
<dt><strong>Specified by:</strong></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/FieldElement.html#reciprocal()">reciprocal</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../org/apache/commons/math3/FieldElement.html" title="interface in org.apache.commons.math3">FieldElement</a>&lt;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&gt;</code></dd>
<dt><span class="strong">Returns:</span></dt><dd>the reciprocal fraction</dd></dl>
</li>
</ul>
<a name="add(org.apache.commons.math3.fraction.Fraction)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>add</h4>
<pre>public&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;add(<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;fraction)</pre>
<div class="block"><p>Adds the value of this fraction to another, returning the result in reduced form.
The algorithm follows Knuth, 4.5.1.</p></div>
<dl>
<dt><strong>Specified by:</strong></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/FieldElement.html#add(T)">add</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../org/apache/commons/math3/FieldElement.html" title="interface in org.apache.commons.math3">FieldElement</a>&lt;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&gt;</code></dd>
<dt><span class="strong">Parameters:</span></dt><dd><code>fraction</code> - the fraction to add, must not be <code>null</code></dd>
<dt><span class="strong">Returns:</span></dt><dd>a <code>Fraction</code> instance with the resulting values</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/NullArgumentException.html" title="class in org.apache.commons.math3.exception">NullArgumentException</a></code> - if the fraction is <code>null</code></dd>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the resulting numerator or denominator exceeds
<code>Integer.MAX_VALUE</code></dd></dl>
</li>
</ul>
<a name="add(int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>add</h4>
<pre>public&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;add(int&nbsp;i)</pre>
<div class="block">Add an integer to the fraction.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>i</code> - the <tt>integer</tt> to add.</dd>
<dt><span class="strong">Returns:</span></dt><dd>this + i</dd></dl>
</li>
</ul>
<a name="subtract(org.apache.commons.math3.fraction.Fraction)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>subtract</h4>
<pre>public&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;subtract(<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;fraction)</pre>
<div class="block"><p>Subtracts the value of another fraction from the value of this one,
returning the result in reduced form.</p></div>
<dl>
<dt><strong>Specified by:</strong></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/FieldElement.html#subtract(T)">subtract</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../org/apache/commons/math3/FieldElement.html" title="interface in org.apache.commons.math3">FieldElement</a>&lt;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&gt;</code></dd>
<dt><span class="strong">Parameters:</span></dt><dd><code>fraction</code> - the fraction to subtract, must not be <code>null</code></dd>
<dt><span class="strong">Returns:</span></dt><dd>a <code>Fraction</code> instance with the resulting values</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/NullArgumentException.html" title="class in org.apache.commons.math3.exception">NullArgumentException</a></code> - if the fraction is <code>null</code></dd>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the resulting numerator or denominator
cannot be represented in an <code>int</code>.</dd></dl>
</li>
</ul>
<a name="subtract(int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>subtract</h4>
<pre>public&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;subtract(int&nbsp;i)</pre>
<div class="block">Subtract an integer from the fraction.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>i</code> - the <tt>integer</tt> to subtract.</dd>
<dt><span class="strong">Returns:</span></dt><dd>this - i</dd></dl>
</li>
</ul>
<a name="multiply(org.apache.commons.math3.fraction.Fraction)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>multiply</h4>
<pre>public&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;multiply(<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;fraction)</pre>
<div class="block"><p>Multiplies the value of this fraction by another, returning the
result in reduced form.</p></div>
<dl>
<dt><strong>Specified by:</strong></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/FieldElement.html#multiply(T)">multiply</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../org/apache/commons/math3/FieldElement.html" title="interface in org.apache.commons.math3">FieldElement</a>&lt;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&gt;</code></dd>
<dt><span class="strong">Parameters:</span></dt><dd><code>fraction</code> - the fraction to multiply by, must not be <code>null</code></dd>
<dt><span class="strong">Returns:</span></dt><dd>a <code>Fraction</code> instance with the resulting values</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/NullArgumentException.html" title="class in org.apache.commons.math3.exception">NullArgumentException</a></code> - if the fraction is <code>null</code></dd>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the resulting numerator or denominator exceeds
<code>Integer.MAX_VALUE</code></dd></dl>
</li>
</ul>
<a name="multiply(int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>multiply</h4>
<pre>public&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;multiply(int&nbsp;i)</pre>
<div class="block">Multiply the fraction by an integer.</div>
<dl>
<dt><strong>Specified by:</strong></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/FieldElement.html#multiply(int)">multiply</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../org/apache/commons/math3/FieldElement.html" title="interface in org.apache.commons.math3">FieldElement</a>&lt;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&gt;</code></dd>
<dt><span class="strong">Parameters:</span></dt><dd><code>i</code> - the <tt>integer</tt> to multiply by.</dd>
<dt><span class="strong">Returns:</span></dt><dd>this * i</dd></dl>
</li>
</ul>
<a name="divide(org.apache.commons.math3.fraction.Fraction)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>divide</h4>
<pre>public&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;divide(<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;fraction)</pre>
<div class="block"><p>Divide the value of this fraction by another.</p></div>
<dl>
<dt><strong>Specified by:</strong></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/FieldElement.html#divide(T)">divide</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../org/apache/commons/math3/FieldElement.html" title="interface in org.apache.commons.math3">FieldElement</a>&lt;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&gt;</code></dd>
<dt><span class="strong">Parameters:</span></dt><dd><code>fraction</code> - the fraction to divide by, must not be <code>null</code></dd>
<dt><span class="strong">Returns:</span></dt><dd>a <code>Fraction</code> instance with the resulting values</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the fraction is <code>null</code></dd>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the fraction to divide by is zero</dd>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the resulting numerator or denominator exceeds
<code>Integer.MAX_VALUE</code></dd></dl>
</li>
</ul>
<a name="divide(int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>divide</h4>
<pre>public&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;divide(int&nbsp;i)</pre>
<div class="block">Divide the fraction by an integer.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>i</code> - the <tt>integer</tt> to divide by.</dd>
<dt><span class="strong">Returns:</span></dt><dd>this * i</dd></dl>
</li>
</ul>
<a name="percentageValue()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>percentageValue</h4>
<pre>public&nbsp;double&nbsp;percentageValue()</pre>
<div class="block"><p>
Gets the fraction percentage as a <tt>double</tt>. This calculates the
fraction as the numerator divided by denominator multiplied by 100.
</p></div>
<dl><dt><span class="strong">Returns:</span></dt><dd>the fraction percentage as a <tt>double</tt>.</dd></dl>
</li>
</ul>
<a name="getReducedFraction(int, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getReducedFraction</h4>
<pre>public static&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&nbsp;getReducedFraction(int&nbsp;numerator,
int&nbsp;denominator)</pre>
<div class="block"><p>Creates a <code>Fraction</code> instance with the 2 parts
of a fraction Y/Z.</p>
<p>Any negative signs are resolved to be on the numerator.</p></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>numerator</code> - the numerator, for example the three in 'three sevenths'</dd><dd><code>denominator</code> - the denominator, for example the seven in 'three sevenths'</dd>
<dt><span class="strong">Returns:</span></dt><dd>a new fraction instance, with the numerator and denominator reduced</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the denominator is <code>zero</code></dd></dl>
</li>
</ul>
<a name="toString()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toString</h4>
<pre>public&nbsp;<a href="http://docs.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;toString()</pre>
<div class="block"><p>
Returns the <code>String</code> representing this fraction, ie
"num / dem" or just "num" if the denominator is one.
</p></div>
<dl>
<dt><strong>Overrides:</strong></dt>
<dd><code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</a></code>&nbsp;in class&nbsp;<code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></code></dd>
<dt><span class="strong">Returns:</span></dt><dd>a string representation of the fraction.</dd><dt><span class="strong">See Also:</span></dt><dd><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang"><code>Object.toString()</code></a></dd></dl>
</li>
</ul>
<a name="getField()">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>getField</h4>
<pre>public&nbsp;<a href="../../../../../org/apache/commons/math3/fraction/FractionField.html" title="class in org.apache.commons.math3.fraction">FractionField</a>&nbsp;getField()</pre>
<div class="block">Get the <a href="../../../../../org/apache/commons/math3/Field.html" title="interface in org.apache.commons.math3"><code>Field</code></a> to which the instance belongs.</div>
<dl>
<dt><strong>Specified by:</strong></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/FieldElement.html#getField()">getField</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../org/apache/commons/math3/FieldElement.html" title="interface in org.apache.commons.math3">FieldElement</a>&lt;<a href="../../../../../org/apache/commons/math3/fraction/Fraction.html" title="class in org.apache.commons.math3.fraction">Fraction</a>&gt;</code></dd>
<dt><span class="strong">Returns:</span></dt><dd><a href="../../../../../org/apache/commons/math3/Field.html" title="interface in org.apache.commons.math3"><code>Field</code></a> to which the instance belongs</dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/Fraction.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><em><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script></em></div>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/commons/math3/fraction/BigFractionFormat.html" title="class in org.apache.commons.math3.fraction"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../org/apache/commons/math3/fraction/FractionConversionException.html" title="class in org.apache.commons.math3.fraction"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/commons/math3/fraction/Fraction.html" target="_top">Frames</a></li>
<li><a href="Fraction.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field_summary">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field_detail">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &#169; 2003&#x2013;2014 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
</body>
</html>