Manna5's Fraction library for Java
Fraction.class
 Fraction.java (reference purposes only)
Description
The Fraction Java class provides four basic operations on
fractions: addition, subtraction, multiplication and division  with
automatic simplifying. Rounding to nearest integer the is available too.
Fields
 static final Fraction ZERO
 Zero as fraction  0/1.
 static final Fraction ONE
 One as fraction  1/1.
Constuctors
 new Fraction (fraction)
 Clone existing fraction.

new
Fraction (numerator, denominator)
 Create a fraction.
 new Fraction (value)
 Convert integer to fraction.
Methods

static Fraction
of (numerator, denominator)
 Optimal way of obtaining a fraction.
 static Fraction of (numerator)
 Like above, but with implicit denominator of 1.
 int numerator ()
 Extract the numerator.
 int denominator ()
 Extract the denominator.
 int round ()
 Round to nearest integer.
 Fraction add (fraction)
 Add fractions.
 Fraction add (value)
 Add integer to fraction.
 Fraction subtract (fraction)
 Subtract fractions.
 Fraction subtract (value)
 Subtract integer from fraction.
 Fraction multiply (fraction)
 Multiply fractions.
 Fraction multiply (value)
 Multiply fraction by integer.
 Fraction divide (fraction)
 Divide fractions.
 Fraction divide (value)
 Divide fraction by integer.
 Fraction opposite ()
 Opposite fraction  for example 2/1 instead of 1/2.
 boolean less (fraction)
 Fraction comparsion  less than?
 boolean greater (fraction)
 Fraction comparsion  greater than?
 boolean equal (fraction)
 Fraction comparsion  equal to?
 String toString ()
 Returns fraction as a string like 3/4.
Jan "Manna5" Mleczko