Java org.apache.commons.lang3.math Fraction fields, constructors, methods, implement or subclass

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

Introduction

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

The text is from its open source code.

Field

StringtoString
Cached output toString (class is immutable).

Method

Fractionadd(final Fraction fraction)

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

doubledoubleValue()

Gets the fraction as a double.

intgetDenominator()

Gets the denominator part of the fraction.

FractiongetFraction(double value)

Creates a Fraction instance from a double value.

This method uses the continued fraction algorithm, computing a maximum of 25 convergents and bounding the denominator by 10,000.

FractiongetFraction(String str)

Creates a Fraction from a String.

The formats accepted are:

  1. double String containing a dot
  2. 'X Y/Z'
  3. 'Y/Z'
  4. 'X' (a simple whole number)

and a .

FractiongetFraction(int numerator, int denominator)

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

Any negative signs are resolved to be on the numerator.

intgetNumerator()

Gets the numerator part of the fraction.

This method may return a value greater than the denominator, an improper fraction, such as the seven in 7/4.

intintValue()

Gets the fraction as an int.

FractionmultiplyBy(final Fraction fraction)

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