APIs

Show:

Initialize the Fraction, numerator and denominator

Constructor

Fraction

(
• numerator
• denominator
)

Parameters:

• numerator Integer

of the fraction

• denominator Integer

the fraction must not be equal to 0

Methods

add

()

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

clone

()

clone the Fraction

Returns:

Fraction:

Returns a clone of the fraction

compareTo

()

Compares this object to another based on size.

gcf

() Number static

Takes two numbers and returns their greatest common factor

Number:

inverse

()

inverse the Fraction

Returns:

Fraction:

Returns the inverse of the fraction

parse

() static

parse a string of the format a/b to a Fraction

subtract

()

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

toString

() String

pretty-printer, converts fractions into whole numbers and fractions

String:

toTeX

() String

pretty-printer to support TeX notation (using with MathJax, KaTeX, etc)

String:

value

() Number

Returns:

Number:

the float number represented by the fraction

Properties

ONE

Fraction final static

Fraction representation of 1.

ZERO

Fraction final static

Fraction representation of 0.