| <!DOCTYPE HTML> |
| <html lang="en"> |
| <head> |
| <!-- Generated by javadoc (21) on Thu Oct 05 19:54:57 CEST 2023 --> |
| <title>Fraction (Apache SIS 1.4 API)</title> |
| <meta name="viewport" content="width=device-width, initial-scale=1"> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <meta name="dc.created" content="2023-10-05"> |
| <meta name="description" content="declaration: module: org.apache.sis.util, package: org.apache.sis.math, class: Fraction"> |
| <meta name="generator" content="javadoc/ClassWriterImpl"> |
| <meta name="keywords" content="org.apache.sis.math.Fraction class"> |
| <meta name="keywords" content="numerator"> |
| <meta name="keywords" content="denominator"> |
| <meta name="keywords" content="valueOf()"> |
| <meta name="keywords" content="unique()"> |
| <meta name="keywords" content="simplify()"> |
| <meta name="keywords" content="inverse()"> |
| <meta name="keywords" content="negate()"> |
| <meta name="keywords" content="add()"> |
| <meta name="keywords" content="subtract()"> |
| <meta name="keywords" content="multiply()"> |
| <meta name="keywords" content="divide()"> |
| <meta name="keywords" content="round()"> |
| <meta name="keywords" content="floor()"> |
| <meta name="keywords" content="ceil()"> |
| <meta name="keywords" content="doubleValue()"> |
| <meta name="keywords" content="floatValue()"> |
| <meta name="keywords" content="longValue()"> |
| <meta name="keywords" content="intValue()"> |
| <meta name="keywords" content="isNaN()"> |
| <meta name="keywords" content="signum()"> |
| <meta name="keywords" content="compareTo()"> |
| <meta name="keywords" content="equals()"> |
| <meta name="keywords" content="hashCode()"> |
| <meta name="keywords" content="toString()"> |
| <link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style"> |
| <link rel="stylesheet" type="text/css" href="../../../../../sis.css" title="Style"> |
| <link rel="stylesheet" type="text/css" href="../../../../../script-dir/jquery-ui.min.css" title="Style"> |
| <script type="text/javascript" src="../../../../../script.js"></script> |
| <script type="text/javascript" src="../../../../../script-dir/jquery-3.6.1.min.js"></script> |
| <script type="text/javascript" src="../../../../../script-dir/jquery-ui.min.js"></script> |
| </head> |
| <body class="class-declaration-page"> |
| <script type="text/javascript">var pathtoroot = "../../../../../"; |
| loadScripts(document, 'script');</script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| <div class="flex-box"> |
| <header role="banner" class="flex-header"> |
| <nav role="navigation"> |
| <!-- ========= START OF TOP NAVBAR ======= --> |
| <div class="top-nav" id="navbar-top"><button id="navbar-toggle-button" aria-controls="navbar-top" aria-expanded="false" aria-label="Toggle navigation links"><span class="nav-bar-toggle-icon"> </span><span class="nav-bar-toggle-icon"> </span><span class="nav-bar-toggle-icon"> </span></button> |
| <div class="skip-nav"><a href="#skip-navbar-top" title="Skip navigation links">Skip navigation links</a></div> |
| <ul id="navbar-top-firstrow" class="nav-list" title="Navigation"> |
| <li><a href="../../../../../index.html">Overview</a></li> |
| <li><a href="../../../../module-summary.html">Module</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="nav-bar-cell1-rev">Class</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#class">Help</a></li> |
| </ul> |
| <ul class="sub-nav-list-small"> |
| <li> |
| <p>Summary:</p> |
| <ul> |
| <li>Nested</li> |
| <li><a href="#field-summary">Field</a></li> |
| <li><a href="#constructor-summary">Constr</a></li> |
| <li><a href="#method-summary">Method</a></li> |
| </ul> |
| </li> |
| <li> |
| <p>Detail:</p> |
| <ul> |
| <li><a href="#field-detail">Field</a></li> |
| <li><a href="#constructor-detail">Constr</a></li> |
| <li><a href="#method-detail">Method</a></li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| <div class="sub-nav"> |
| <div id="navbar-sub-list"> |
| <ul class="sub-nav-list"> |
| <li>Summary: </li> |
| <li>Nested | </li> |
| <li><a href="#field-summary">Field</a> | </li> |
| <li><a href="#constructor-summary">Constr</a> | </li> |
| <li><a href="#method-summary">Method</a></li> |
| </ul> |
| <ul class="sub-nav-list"> |
| <li>Detail: </li> |
| <li><a href="#field-detail">Field</a> | </li> |
| <li><a href="#constructor-detail">Constr</a> | </li> |
| <li><a href="#method-detail">Method</a></li> |
| </ul> |
| </div> |
| <div class="nav-list-search"><a href="../../../../../search.html">SEARCH</a> |
| <input type="text" id="search-input" disabled placeholder="Search"> |
| <input type="reset" id="reset-button" disabled value="reset"> |
| </div> |
| </div> |
| <!-- ========= END OF TOP NAVBAR ========= --> |
| <span class="skip-nav" id="skip-navbar-top"></span></nav> |
| </header> |
| <div class="flex-content"> |
| <main role="main"> |
| <!-- ======== START OF CLASS DATA ======== --> |
| <div class="header"> |
| <div class="sub-title"><span class="module-label-in-type">Module</span> <a href="../../../../module-summary.html">org.apache.sis.util</a></div> |
| <div class="sub-title"><span class="package-label-in-type">Package</span> <a href="package-summary.html">org.apache.sis.math</a></div> |
| <h1 title="Class Fraction" class="title">Class Fraction</h1> |
| </div> |
| <div class="inheritance" title="Inheritance Tree"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a> |
| <div class="inheritance"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Number.html" title="class or interface in java.lang" class="external-link">Number</a> |
| <div class="inheritance">Fraction</div> |
| </div> |
| </div> |
| <section class="class-description" id="class-description"> |
| <dl class="notes"> |
| <dt>All Implemented Interfaces:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/Serializable.html" title="class or interface in java.io" class="external-link">Serializable</a></code>, <code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Comparable.html" title="class or interface in java.lang" class="external-link">Comparable</a><<a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a>></code></dd> |
| </dl> |
| <hr> |
| <div class="type-signature"><span class="modifiers">public final class </span><span class="element-name type-name-label">Fraction</span> |
| <span class="extends-implements">extends <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Number.html" title="class or interface in java.lang" class="external-link">Number</a> |
| implements <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Comparable.html" title="class or interface in java.lang" class="external-link">Comparable</a><<a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a>>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/Serializable.html" title="class or interface in java.io" class="external-link">Serializable</a></span></div> |
| <div class="block">A value class for rational numbers. <code>Fraction</code> objects are represented by a <a href="#numerator">numerator</a> and |
| a <a href="#denominator">denominator</a> stored at 32 bits integers. Fractions can be <a href="#simplify()">simplified</a>. |
| All <code>Fraction</code> instances are immutable and thus inherently thread-safe.</div> |
| <dl class="notes"> |
| <dt>Since:</dt> |
| <dd>0.8</dd> |
| <dt>See Also:</dt> |
| <dd> |
| <ul class="tag-list"> |
| <li><a href="../../../../../serialized-form.html#org.apache.sis.math.Fraction">Serialized Form</a></li> |
| </ul> |
| </dd> |
| </dl> |
| </section> |
| <section class="summary"> |
| <ul class="summary-list"> |
| <!-- =========== FIELD SUMMARY =========== --> |
| <li> |
| <section class="field-summary" id="field-summary"> |
| <h2>Field Summary</h2> |
| <div class="caption"><span>Fields</span></div> |
| <div class="summary-table three-column-summary"> |
| <div class="table-header col-first">Modifier and Type</div> |
| <div class="table-header col-second">Field</div> |
| <div class="table-header col-last">Description</div> |
| <div class="col-first even-row-color"><code>final int</code></div> |
| <div class="col-second even-row-color"><code><a href="#denominator" class="member-name-link">denominator</a></code></div> |
| <div class="col-last even-row-color"> |
| <div class="block">The <var>b</var> term in the <var>a</var>/<var>b</var> fraction.</div> |
| </div> |
| <div class="col-first odd-row-color"><code>final int</code></div> |
| <div class="col-second odd-row-color"><code><a href="#numerator" class="member-name-link">numerator</a></code></div> |
| <div class="col-last odd-row-color"> |
| <div class="block">The <var>a</var> term in the <var>a</var>/<var>b</var> fraction.</div> |
| </div> |
| </div> |
| </section> |
| </li> |
| <!-- ======== CONSTRUCTOR SUMMARY ======== --> |
| <li> |
| <section class="constructor-summary" id="constructor-summary"> |
| <h2>Constructor Summary</h2> |
| <div class="caption"><span>Constructors</span></div> |
| <div class="summary-table two-column-summary"> |
| <div class="table-header col-first">Constructor</div> |
| <div class="table-header col-last">Description</div> |
| <div class="col-constructor-name even-row-color"><code><a href="#%3Cinit%3E(int,int)" class="member-name-link">Fraction</a><wbr>(int numerator, |
| int denominator)</code></div> |
| <div class="col-last even-row-color"> |
| <div class="block">Creates a new fraction.</div> |
| </div> |
| <div class="col-constructor-name odd-row-color"><code><a href="#%3Cinit%3E(java.lang.String)" class="member-name-link">Fraction</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a> s)</code></div> |
| <div class="col-last odd-row-color"> |
| <div class="block">Creates a new fraction from the given text.</div> |
| </div> |
| </div> |
| </section> |
| </li> |
| <!-- ========== METHOD SUMMARY =========== --> |
| <li> |
| <section class="method-summary" id="method-summary"> |
| <h2>Method Summary</h2> |
| <div id="method-summary-table"> |
| <div class="table-tabs" role="tablist" aria-orientation="horizontal"><button id="method-summary-table-tab0" role="tab" aria-selected="true" aria-controls="method-summary-table.tabpanel" tabindex="0" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table', 3)" class="active-table-tab">All Methods</button><button id="method-summary-table-tab1" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab1', 3)" class="table-tab">Static Methods</button><button id="method-summary-table-tab2" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab2', 3)" class="table-tab">Instance Methods</button><button id="method-summary-table-tab4" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab4', 3)" class="table-tab">Concrete Methods</button></div> |
| <div id="method-summary-table.tabpanel" role="tabpanel"> |
| <div class="summary-table three-column-summary" aria-labelledby="method-summary-table-tab0"> |
| <div class="table-header col-first">Modifier and Type</div> |
| <div class="table-header col-second">Method</div> |
| <div class="table-header col-last">Description</div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#add(org.apache.sis.math.Fraction)" class="member-name-link">add</a><wbr>(<a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a> other)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Returns the simplified result of adding the given fraction to this fraction.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>int</code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#ceil()" class="member-name-link">ceil</a>()</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Returns this fraction rounded toward positive infinity.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>int</code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#compareTo(org.apache.sis.math.Fraction)" class="member-name-link">compareTo</a><wbr>(<a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a> other)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Compares this fraction with the given one for order.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a></code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#divide(org.apache.sis.math.Fraction)" class="member-name-link">divide</a><wbr>(<a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a> other)</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Returns the simplified result of dividing this fraction by the given fraction.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>double</code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#doubleValue()" class="member-name-link">doubleValue</a>()</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Returns the fraction as a double-precision floating point number.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>boolean</code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#equals(java.lang.Object)" class="member-name-link">equals</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a> other)</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Compares this fraction with the given object for equality.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>float</code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#floatValue()" class="member-name-link">floatValue</a>()</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Returns the fraction as a single-precision floating point number.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>int</code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#floor()" class="member-name-link">floor</a>()</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Returns this fraction rounded toward negative infinity.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>int</code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#hashCode()" class="member-name-link">hashCode</a>()</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Returns a hash code value for this fraction.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>int</code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#intValue()" class="member-name-link">intValue</a>()</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Returns this fraction rounded toward zero.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#inverse()" class="member-name-link">inverse</a>()</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Returns the inverse value of this fraction.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>boolean</code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#isNaN()" class="member-name-link">isNaN</a>()</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Returns <code>true</code> if the numerator and denominator are both zero.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>long</code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#longValue()" class="member-name-link">longValue</a>()</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Returns this fraction rounded toward zero.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a></code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#multiply(org.apache.sis.math.Fraction)" class="member-name-link">multiply</a><wbr>(<a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a> other)</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Returns the simplified result of multiplying the given fraction with this fraction.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#negate()" class="member-name-link">negate</a>()</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Returns the negative value of this fraction.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>int</code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#round()" class="member-name-link">round</a>()</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Returns this fraction rounded toward nearest integer.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>int</code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#signum()" class="member-name-link">signum</a>()</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Returns the sign of this fraction.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a></code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#simplify()" class="member-name-link">simplify</a>()</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Returns a fraction equivalent to <code>this</code> but represented by the smallest possible numerator |
| and denominator values.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#subtract(org.apache.sis.math.Fraction)" class="member-name-link">subtract</a><wbr>(<a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a> other)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Returns the simplified result of subtracting the given fraction from this fraction.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#toString()" class="member-name-link">toString</a>()</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Returns a string representation of this fraction.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#unique()" class="member-name-link">unique</a>()</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Returns a unique fraction instance equals to <code>this</code>.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static <a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a></code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#valueOf(double)" class="member-name-link">valueOf</a><wbr>(double value)</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"> |
| <div class="block">Converts the given IEEE 754 double-precision value to a fraction.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static <a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#valueOf(long,long)" class="member-name-link">valueOf</a><wbr>(long numerator, |
| long denominator)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"> |
| <div class="block">Returns the given fraction after simplification.</div> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="inherited-list"> |
| <h3 id="methods-inherited-from-class-Number">Methods inherited from class <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Number.html" title="class or interface in java.lang" class="external-link">Number</a></h3> |
| <code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Number.html#byteValue()" title="class or interface in java.lang" class="external-link">byteValue</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Number.html#shortValue()" title="class or interface in java.lang" class="external-link">shortValue</a></code></div> |
| <div class="inherited-list"> |
| <h3 id="methods-inherited-from-class-Object">Methods inherited from class <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></h3> |
| <code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#clone()" title="class or interface in java.lang" class="external-link">clone</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#finalize()" title="class or interface in java.lang" class="external-link">finalize</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#getClass()" title="class or interface in java.lang" class="external-link">getClass</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#notify()" title="class or interface in java.lang" class="external-link">notify</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#notifyAll()" title="class or interface in java.lang" class="external-link">notifyAll</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#wait()" title="class or interface in java.lang" class="external-link">wait</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#wait(long)" title="class or interface in java.lang" class="external-link">wait</a>, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#wait(long,int)" title="class or interface in java.lang" class="external-link">wait</a></code></div> |
| </section> |
| </li> |
| </ul> |
| </section> |
| <section class="details"> |
| <ul class="details-list"> |
| <!-- ============ FIELD DETAIL =========== --> |
| <li> |
| <section class="field-details" id="field-detail"> |
| <h2>Field Details</h2> |
| <ul class="member-list"> |
| <li> |
| <section class="detail" id="numerator"> |
| <h3>numerator</h3> |
| <div class="member-signature"><span class="modifiers">public final</span> <span class="return-type">int</span> <span class="element-name">numerator</span></div> |
| <div class="block">The <var>a</var> term in the <var>a</var>/<var>b</var> fraction. |
| Can be positive, negative or zero.</div> |
| <dl class="notes"> |
| <dt>See Also:</dt> |
| <dd> |
| <ul class="tag-list"> |
| <li><a href="#doubleValue()"><code>doubleValue()</code></a></li> |
| </ul> |
| </dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="denominator"> |
| <h3>denominator</h3> |
| <div class="member-signature"><span class="modifiers">public final</span> <span class="return-type">int</span> <span class="element-name">denominator</span></div> |
| <div class="block">The <var>b</var> term in the <var>a</var>/<var>b</var> fraction. |
| Can be positive, negative or zero. If zero, then the fraction <a href="#doubleValue()">floating point</a> |
| value will be positive infinity, negative infinity or NaN depending on the <a href="#numerator">numerator</a> value.</div> |
| <dl class="notes"> |
| <dt>See Also:</dt> |
| <dd> |
| <ul class="tag-list"> |
| <li><a href="#doubleValue()"><code>doubleValue()</code></a></li> |
| </ul> |
| </dd> |
| </dl> |
| </section> |
| </li> |
| </ul> |
| </section> |
| </li> |
| <!-- ========= CONSTRUCTOR DETAIL ======== --> |
| <li> |
| <section class="constructor-details" id="constructor-detail"> |
| <h2>Constructor Details</h2> |
| <ul class="member-list"> |
| <li> |
| <section class="detail" id="<init>(int,int)"> |
| <h3>Fraction</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="element-name">Fraction</span><wbr><span class="parameters">(int numerator, |
| int denominator)</span></div> |
| <div class="block">Creates a new fraction. This constructor stores the fraction exactly as specified; it does not simplify it. |
| The fraction can be simplified after construction by a call to <a href="#simplify()"><code>simplify()</code></a>.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>numerator</code> - the <var>a</var> term in the <var>a</var>/<var>b</var> fraction.</dd> |
| <dd><code>denominator</code> - the <var>b</var> term in the <var>a</var>/<var>b</var> fraction.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="<init>(java.lang.String)"> |
| <h3>Fraction</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="element-name">Fraction</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a> s)</span> |
| throws <span class="exceptions"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/NumberFormatException.html" title="class or interface in java.lang" class="external-link">NumberFormatException</a></span></div> |
| <div class="block">Creates a new fraction from the given text. This constructor is the converse of <a href="#toString()"><code>toString()</code></a> method. |
| It can parse single numbers like "3", fractions like "2/3", Unicode characters like "⅔" and infinity symbols |
| "∞" and "−∞". The given text shall not contain spaces.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>s</code> - the text to parse.</dd> |
| <dt>Throws:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/NumberFormatException.html" title="class or interface in java.lang" class="external-link">NumberFormatException</a></code> - if the given text cannot be parsed.</dd> |
| <dt>Since:</dt> |
| <dd>1.0</dd> |
| </dl> |
| </section> |
| </li> |
| </ul> |
| </section> |
| </li> |
| <!-- ============ METHOD DETAIL ========== --> |
| <li> |
| <section class="method-details" id="method-detail"> |
| <h2>Method Details</h2> |
| <ul class="member-list"> |
| <li> |
| <section class="detail" id="valueOf(long,long)"> |
| <h3>valueOf</h3> |
| <div class="member-signature"><span class="modifiers">public static</span> <span class="return-type"><a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a></span> <span class="element-name">valueOf</span><wbr><span class="parameters">(long numerator, |
| long denominator)</span></div> |
| <div class="block">Returns the given fraction after simplification. |
| If the numerator or denominator is still too large for 32 bit integer after simplification, |
| then an <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/ArithmeticException.html" title="class or interface in java.lang" class="external-link"><code>ArithmeticException</code></a> is thrown.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>numerator</code> - numerator of the fraction to return.</dd> |
| <dd><code>denominator</code> - denominator of the fraction to return.</dd> |
| <dt>Returns:</dt> |
| <dd>the simplified fraction.</dd> |
| <dt>Throws:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/ArithmeticException.html" title="class or interface in java.lang" class="external-link">ArithmeticException</a></code> - if the numerator and denominator cannot be represented by 32 bit integers.</dd> |
| <dt>Since:</dt> |
| <dd>1.4</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="valueOf(double)"> |
| <h3>valueOf</h3> |
| <div class="member-signature"><span class="modifiers">public static</span> <span class="return-type"><a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a></span> <span class="element-name">valueOf</span><wbr><span class="parameters">(double value)</span></div> |
| <div class="block">Converts the given IEEE 754 double-precision value to a fraction. If successful, this method returns a fraction |
| such as <a href="#doubleValue()"><code>doubleValue()</code></a> is equal to the given value in the sense of <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Double.html#equals(java.lang.Object)" title="class or interface in java.lang" class="external-link"><code>Double.equals(Object)</code></a>: |
| infinities, positive and negative zeros are preserved, but various NaN values are collapsed to a single NaN value. |
| |
| <p>This method accepts only values between <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Integer.html#MIN_VALUE" title="class or interface in java.lang" class="external-link">-2147483648</a> and <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Integer.html#MAX_VALUE" title="class or interface in java.lang" class="external-link">2147483647</a> inclusive, |
| i.e. values in the range of 32-bits integers. If the given value has fraction digits, then the validity range |
| will be smaller depending on the <a href="#denominator">denominator</a> required for representing that value.</p> |
| |
| <h4 id="design-note-heading">Design note</h4> |
| This method does not return approximated values because it is difficult to choose which fraction is best. |
| For example, choosing an approximated fraction for π value is quite arbitrary, and searching the fraction |
| closer than any other fraction representable by this class is computationally expensive. |
| Even with common fractions, the algorithm currently implemented in this class can detect that 1.6666666666666667 |
| <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Double.html#equals(java.lang.Object)" title="class or interface in java.lang" class="external-link">is equal to</a> 5⁄3 but cannot detect easily that 1.66666666666666 (same number |
| with two decimal digits dropped) is close to 5⁄3.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>value</code> - the double-precision value to convert to a fraction.</dd> |
| <dt>Returns:</dt> |
| <dd>a fraction such as <a href="#doubleValue()"><code>doubleValue()</code></a> is equal to the given value.</dd> |
| <dt>Throws:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">IllegalArgumentException</a></code> - if the given value cannot be converted to a fraction.</dd> |
| <dt>Since:</dt> |
| <dd>1.0</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="unique()"> |
| <h3>unique</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type"><a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a></span> <span class="element-name">unique</span>()</div> |
| <div class="block">Returns a unique fraction instance equals to <code>this</code>. |
| If this method has been invoked previously on another <code>Fraction</code> with the same value than <code>this</code>, |
| then that previous instance is returned (provided that it has not yet been garbage collected). Otherwise this |
| method adds this fraction to the pool of fractions that may be returned in next <code>unique()</code> invocations, |
| then returns <code>this</code>. |
| |
| <p>This method is useful for saving memory when a potentially large amount of <code>Fraction</code> instances will |
| be kept for a long time and many instances are likely to have the same values. |
| It is usually not worth to invoke this method for short-lived instances.</p></div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>a unique instance of a fraction equals to <code>this</code>.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="simplify()"> |
| <h3>simplify</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type"><a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a></span> <span class="element-name">simplify</span>()</div> |
| <div class="block">Returns a fraction equivalent to <code>this</code> but represented by the smallest possible numerator |
| and denominator values. If this fraction cannot be simplified, then this method returns <code>this</code>.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>the simplest fraction equivalent to this fraction.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="inverse()"> |
| <h3>inverse</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type"><a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a></span> <span class="element-name">inverse</span>()</div> |
| <div class="block">Returns the inverse value of this fraction. |
| This method does not simplify the fraction.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>the result of <code>1/this</code>.</dd> |
| <dt>Throws:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/ArithmeticException.html" title="class or interface in java.lang" class="external-link">ArithmeticException</a></code> - if the result overflows.</dd> |
| <dt>Since:</dt> |
| <dd>1.4</dd> |
| <dt>See Also:</dt> |
| <dd> |
| <ul class="tag-list"> |
| <li><a href="#divide(org.apache.sis.math.Fraction)"><code>divide(Fraction)</code></a></li> |
| </ul> |
| </dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="negate()"> |
| <h3>negate</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type"><a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a></span> <span class="element-name">negate</span>()</div> |
| <div class="block">Returns the negative value of this fraction. |
| This method does not simplify the fraction.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>the result of <code>-this</code>.</dd> |
| <dt>Throws:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/ArithmeticException.html" title="class or interface in java.lang" class="external-link">ArithmeticException</a></code> - if the result overflows.</dd> |
| <dt>See Also:</dt> |
| <dd> |
| <ul class="tag-list"> |
| <li><a href="#subtract(org.apache.sis.math.Fraction)"><code>subtract(Fraction)</code></a></li> |
| </ul> |
| </dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="add(org.apache.sis.math.Fraction)"> |
| <h3>add</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type"><a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a></span> <span class="element-name">add</span><wbr><span class="parameters">(<a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a> other)</span></div> |
| <div class="block">Returns the simplified result of adding the given fraction to this fraction.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>other</code> - the fraction to add to this fraction.</dd> |
| <dt>Returns:</dt> |
| <dd>the simplified result of <code>this</code> + <code>other</code>.</dd> |
| <dt>Throws:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/ArithmeticException.html" title="class or interface in java.lang" class="external-link">ArithmeticException</a></code> - if the result overflows.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="subtract(org.apache.sis.math.Fraction)"> |
| <h3>subtract</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type"><a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a></span> <span class="element-name">subtract</span><wbr><span class="parameters">(<a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a> other)</span></div> |
| <div class="block">Returns the simplified result of subtracting the given fraction from this fraction.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>other</code> - the fraction to subtract from this fraction.</dd> |
| <dt>Returns:</dt> |
| <dd>the simplified result of <code>this</code> - <code>other</code>.</dd> |
| <dt>Throws:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/ArithmeticException.html" title="class or interface in java.lang" class="external-link">ArithmeticException</a></code> - if the result overflows.</dd> |
| <dt>See Also:</dt> |
| <dd> |
| <ul class="tag-list"> |
| <li><a href="#negate()"><code>negate()</code></a></li> |
| </ul> |
| </dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="multiply(org.apache.sis.math.Fraction)"> |
| <h3>multiply</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type"><a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a></span> <span class="element-name">multiply</span><wbr><span class="parameters">(<a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a> other)</span></div> |
| <div class="block">Returns the simplified result of multiplying the given fraction with this fraction.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>other</code> - the fraction to multiply with this fraction.</dd> |
| <dt>Returns:</dt> |
| <dd>the simplified result of <code>this</code> × <code>other</code>.</dd> |
| <dt>Throws:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/ArithmeticException.html" title="class or interface in java.lang" class="external-link">ArithmeticException</a></code> - if the result overflows.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="divide(org.apache.sis.math.Fraction)"> |
| <h3>divide</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type"><a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a></span> <span class="element-name">divide</span><wbr><span class="parameters">(<a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a> other)</span></div> |
| <div class="block">Returns the simplified result of dividing this fraction by the given fraction.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>other</code> - the fraction by which to divide this fraction.</dd> |
| <dt>Returns:</dt> |
| <dd>the simplified result of <code>this</code> ∕ <code>other</code>.</dd> |
| <dt>Throws:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/ArithmeticException.html" title="class or interface in java.lang" class="external-link">ArithmeticException</a></code> - if the result overflows.</dd> |
| <dt>See Also:</dt> |
| <dd> |
| <ul class="tag-list"> |
| <li><a href="#inverse()"><code>inverse()</code></a></li> |
| </ul> |
| </dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="round()"> |
| <h3>round</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type">int</span> <span class="element-name">round</span>()</div> |
| <div class="block">Returns this fraction rounded toward nearest integer. If the result is located |
| at equal distance from the two nearest integers, then rounds to the even one.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd><a href="#numerator"><code>numerator</code></a> / <a href="#denominator"><code>denominator</code></a> rounded toward nearest integer.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="floor()"> |
| <h3>floor</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type">int</span> <span class="element-name">floor</span>()</div> |
| <div class="block">Returns this fraction rounded toward negative infinity. |
| This is different from the default operation on primitive types, which rounds toward zero. |
| |
| <p><b>Tip:</b> if the numerator and the denominator are both positive or both negative, |
| then the result is positive and identical to <code>numerator / denominator</code>.</p></div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd><a href="#numerator"><code>numerator</code></a> / <a href="#denominator"><code>denominator</code></a> rounded toward negative infinity.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="ceil()"> |
| <h3>ceil</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type">int</span> <span class="element-name">ceil</span>()</div> |
| <div class="block">Returns this fraction rounded toward positive infinity. |
| This is different from the default operation on primitive types, which rounds toward zero.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd><a href="#numerator"><code>numerator</code></a> / <a href="#denominator"><code>denominator</code></a> rounded toward positive infinity.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="doubleValue()"> |
| <h3>doubleValue</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type">double</span> <span class="element-name">doubleValue</span>()</div> |
| <div class="block">Returns the fraction as a double-precision floating point number. |
| Special cases: |
| |
| <ul> |
| <li>If the <a href="#numerator">numerator</a> and the <a href="#denominator">denominator</a> are both 0, |
| then this method returns <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Double.html#NaN" title="class or interface in java.lang" class="external-link"><code>Double.NaN</code></a>.</li> |
| <li>If only the <a href="#denominator">denominator</a> is zero, then this method returns |
| <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Double.html#POSITIVE_INFINITY" title="class or interface in java.lang" class="external-link">positive infinity</a> or |
| <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Double.html#NEGATIVE_INFINITY" title="class or interface in java.lang" class="external-link">negative infinity</a> accordingly the <a href="#numerator">numerator</a> sign.</li> |
| </ul></div> |
| <dl class="notes"> |
| <dt>Specified by:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Number.html#doubleValue()" title="class or interface in java.lang" class="external-link">doubleValue</a></code> in class <code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Number.html" title="class or interface in java.lang" class="external-link">Number</a></code></dd> |
| <dt>Returns:</dt> |
| <dd>this fraction as a floating point number.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="floatValue()"> |
| <h3>floatValue</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type">float</span> <span class="element-name">floatValue</span>()</div> |
| <div class="block">Returns the fraction as a single-precision floating point number. |
| Special cases: |
| |
| <ul> |
| <li>If the <a href="#numerator">numerator</a> and the <a href="#denominator">denominator</a> are both 0, |
| then this method returns <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Float.html#NaN" title="class or interface in java.lang" class="external-link"><code>Float.NaN</code></a>.</li> |
| <li>If only the <a href="#denominator">denominator</a> is zero, then this method returns |
| <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Float.html#POSITIVE_INFINITY" title="class or interface in java.lang" class="external-link">positive infinity</a> or |
| <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Float.html#NEGATIVE_INFINITY" title="class or interface in java.lang" class="external-link">negative infinity</a> accordingly the <a href="#numerator">numerator</a> sign.</li> |
| </ul></div> |
| <dl class="notes"> |
| <dt>Specified by:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Number.html#floatValue()" title="class or interface in java.lang" class="external-link">floatValue</a></code> in class <code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Number.html" title="class or interface in java.lang" class="external-link">Number</a></code></dd> |
| <dt>Returns:</dt> |
| <dd>this fraction as a floating point number.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="longValue()"> |
| <h3>longValue</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type">long</span> <span class="element-name">longValue</span>()</div> |
| <div class="block">Returns this fraction rounded toward zero. |
| If the fraction value <a href="#isNaN()">is NaN</a>, then this method returns 0. |
| If the fraction value is positive or negative infinity, then this method returns |
| <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Long.html#MAX_VALUE" title="class or interface in java.lang" class="external-link"><code>Long.MAX_VALUE</code></a> or <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Long.html#MIN_VALUE" title="class or interface in java.lang" class="external-link"><code>Long.MIN_VALUE</code></a> respectively.</div> |
| <dl class="notes"> |
| <dt>Specified by:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Number.html#longValue()" title="class or interface in java.lang" class="external-link">longValue</a></code> in class <code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Number.html" title="class or interface in java.lang" class="external-link">Number</a></code></dd> |
| <dt>Returns:</dt> |
| <dd>this fraction rounded toward zero.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="intValue()"> |
| <h3>intValue</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type">int</span> <span class="element-name">intValue</span>()</div> |
| <div class="block">Returns this fraction rounded toward zero. |
| If the fraction value <a href="#isNaN()">is NaN</a>, then this method returns 0. |
| If the fraction value is positive or negative infinity, then this method returns |
| <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Integer.html#MAX_VALUE" title="class or interface in java.lang" class="external-link"><code>Integer.MAX_VALUE</code></a> or <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Integer.html#MIN_VALUE" title="class or interface in java.lang" class="external-link"><code>Integer.MIN_VALUE</code></a> respectively.</div> |
| <dl class="notes"> |
| <dt>Specified by:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Number.html#intValue()" title="class or interface in java.lang" class="external-link">intValue</a></code> in class <code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Number.html" title="class or interface in java.lang" class="external-link">Number</a></code></dd> |
| <dt>Returns:</dt> |
| <dd><a href="#numerator"><code>numerator</code></a> / <a href="#denominator"><code>denominator</code></a> rounded toward zero.</dd> |
| <dt>See Also:</dt> |
| <dd> |
| <ul class="tag-list"> |
| <li><a href="#round()"><code>round()</code></a></li> |
| <li><a href="#floor()"><code>floor()</code></a></li> |
| <li><a href="#ceil()"><code>ceil()</code></a></li> |
| </ul> |
| </dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="isNaN()"> |
| <h3>isNaN</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type">boolean</span> <span class="element-name">isNaN</span>()</div> |
| <div class="block">Returns <code>true</code> if the numerator and denominator are both zero.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>whether this fraction is 0/0.</dd> |
| <dt>Since:</dt> |
| <dd>1.4</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="signum()"> |
| <h3>signum</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type">int</span> <span class="element-name">signum</span>()</div> |
| <div class="block">Returns the sign of this fraction. The return value is -1 if this fraction is negative; |
| 0 if the numerator is zero; and 1 if this fraction is positive.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>the sign of this fraction.</dd> |
| <dt>Since:</dt> |
| <dd>1.0</dd> |
| <dt>See Also:</dt> |
| <dd> |
| <ul class="tag-list"> |
| <li><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Integer.html#signum(int)" title="class or interface in java.lang" class="external-link"><code>Integer.signum(int)</code></a></li> |
| </ul> |
| </dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="compareTo(org.apache.sis.math.Fraction)"> |
| <h3>compareTo</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type">int</span> <span class="element-name">compareTo</span><wbr><span class="parameters">(<a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a> other)</span></div> |
| <div class="block">Compares this fraction with the given one for order.</div> |
| <dl class="notes"> |
| <dt>Specified by:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Comparable.html#compareTo(T)" title="class or interface in java.lang" class="external-link">compareTo</a></code> in interface <code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Comparable.html" title="class or interface in java.lang" class="external-link">Comparable</a><<a href="Fraction.html" title="class in org.apache.sis.math">Fraction</a>></code></dd> |
| <dt>Parameters:</dt> |
| <dd><code>other</code> - the fraction to compare to this fraction for ordering.</dd> |
| <dt>Returns:</dt> |
| <dd>a negative number if this fraction is smaller than the given fraction, |
| a positive number if greater, or 0 if equals.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="equals(java.lang.Object)"> |
| <h3>equals</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type">boolean</span> <span class="element-name">equals</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a> other)</span></div> |
| <div class="block">Compares this fraction with the given object for equality. This method returns <code>true</code> only if |
| the two objects are fractions with same <a href="#numerator">numerator</a> and <a href="#denominator">denominator</a> values. |
| Fractions with different values are not considered equal even if the two fraction are equivalent.</div> |
| <dl class="notes"> |
| <dt>Overrides:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang" class="external-link">equals</a></code> in class <code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></code></dd> |
| <dt>Parameters:</dt> |
| <dd><code>other</code> - the object to compare with this fraction for equality.</dd> |
| <dt>Returns:</dt> |
| <dd><code>true</code> if the given object is another fraction with the same numerator and denominator values.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="hashCode()"> |
| <h3>hashCode</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type">int</span> <span class="element-name">hashCode</span>()</div> |
| <div class="block">Returns a hash code value for this fraction.</div> |
| <dl class="notes"> |
| <dt>Overrides:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#hashCode()" title="class or interface in java.lang" class="external-link">hashCode</a></code> in class <code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></code></dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="toString()"> |
| <h3>toString</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></span> <span class="element-name">toString</span>()</div> |
| <div class="block">Returns a string representation of this fraction. |
| This method returns Unicode symbol if possible.</div> |
| <dl class="notes"> |
| <dt>Overrides:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#toString()" title="class or interface in java.lang" class="external-link">toString</a></code> in class <code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></code></dd> |
| <dt>Returns:</dt> |
| <dd>a string representation of this fraction.</dd> |
| </dl> |
| </section> |
| </li> |
| </ul> |
| </section> |
| </li> |
| </ul> |
| </section> |
| <!-- ========= END OF CLASS DATA ========= --> |
| </main> |
| </div> |
| </div> |
| </body> |
| </html> |