Package net.imglib2.util
Class Fraction
- java.lang.Object
-
- net.imglib2.util.Fraction
-
public class Fraction extends java.lang.Object
Implements the concept of fractions- Author:
- Stephan Preibisch
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Fraction
clone()
void
div(Fraction fraction)
long
getDenominator()
long
getNumerator()
double
getRatio()
void
invert()
Inverts this fraction by exchanging numerator and denominatorvoid
mul(Fraction fraction)
long
mulCeil(long value)
Multiply the value with this fraction.
-
-
-
Constructor Detail
-
Fraction
public Fraction(long numerator, long denominator)
Creates a new fraction with the respective values- Parameters:
numerator
- (above fraction bar)denominator
- (below fraction bar)
-
Fraction
public Fraction()
Instantiate aFraction
with a value of 1
-
-
Method Detail
-
getNumerator
public long getNumerator()
- Returns:
- - the numerator (above the fraction bar)
-
getDenominator
public long getDenominator()
- Returns:
- - the denominator (below the fraction bar)
-
getRatio
public double getRatio()
- Returns:
- - an estimate of the ratio in double, i.e. numerator/denominator
-
invert
public void invert()
Inverts this fraction by exchanging numerator and denominator
-
mul
public void mul(Fraction fraction)
-
div
public void div(Fraction fraction)
-
mulCeil
public long mulCeil(long value)
Multiply the value with this fraction. Return the ceiled value (e.g. 10.2 = 11) if the result is a fraction.- Parameters:
value
-- Returns:
-
clone
public Fraction clone()
- Overrides:
clone
in classjava.lang.Object
-
-