com.notuvy.util
Class Fractional

java.lang.Object
  extended by com.notuvy.util.Fractional

public abstract class Fractional
extends Object

Representation of a numeric real value in the range [0, 1]. If a value ouside this range is given, either 0 or 1 will be used. User: murali Date: Apr 16, 2009 Time: 6:18:00 PM


Constructor Summary
protected Fractional(double pValue)
           
 
Method Summary
 double getValue()
           
 boolean isZero()
          Because "== 0" is unreliable for floating point values, we have this method to do the analogous check.
static Fractional ratio(int pNumerator, int pDenominator)
           
static Fractional ratio(long pNumerator, long pDenominator)
           
 String toPercentage()
           
 String toString()
           
static Fractional valueOf(double pValue)
           
static Fractional valueOf(float pValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Fractional

protected Fractional(double pValue)
Method Detail

valueOf

public static Fractional valueOf(double pValue)

valueOf

public static Fractional valueOf(float pValue)

ratio

public static Fractional ratio(int pNumerator,
                               int pDenominator)

ratio

public static Fractional ratio(long pNumerator,
                               long pDenominator)

getValue

public double getValue()

isZero

public boolean isZero()
Because "== 0" is unreliable for floating point values, we have this method to do the analogous check.

Returns:
true if equivalent to zero (i.e. a sufficiently small value).

toPercentage

public String toPercentage()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All Rights Reserved.