Java org.apache.commons.math3.fraction Fraction fields, constructors, methods, implement or subclass

Example usage for Java org.apache.commons.math3.fraction Fraction fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for org.apache.commons.math3.fraction Fraction.

The text is from its open source code.

Field

FractionONE
A fraction representing "1".
FractionZERO
A fraction representing "0".

Constructor

Fraction(double value, int maxDenominator)
Create a fraction given the double value and maximum denominator.
Fraction(int num, int den)
Create a fraction given the numerator and denominator.
Fraction(double value)
Create a fraction given the double value.
Fraction(int num)
Create a fraction from an int.

Method

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

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

Fractionadd(final int i)
Add an integer to the fraction.
Fractiondivide(Fraction fraction)

Divide the value of this fraction by another.

Fractiondivide(final int i)
Divide the fraction by an integer.
doubledoubleValue()
Gets the fraction as a double.
intgetDenominator()
Access the denominator.
intgetNumerator()
Access the numerator.
intintValue()
Gets the fraction as an int.
Fractionmultiply(Fraction fraction)

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

Fractionmultiply(final int i)
Multiply the fraction by an integer.
Fractionnegate()
Return the additive inverse of this fraction.
doublepercentageValue()

Gets the fraction percentage as a double.

Fractionsubtract(Fraction fraction)

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

Fractionsubtract(final int i)
Subtract an integer from the fraction.
StringtoString()

Returns the String representing this fraction, ie "num / dem" or just "num" if the denominator is one.