com.vividsolutions.jump.geom.precision
Class NumberPrecisionReducer
java.lang.Object
com.vividsolutions.jump.geom.precision.NumberPrecisionReducer
public class NumberPrecisionReducer
- extends java.lang.Object
Reduces the precision of a number
by rounding it off after scaling by a given scale factor.
|
Constructor Summary |
NumberPrecisionReducer()
|
NumberPrecisionReducer(double scaleFactor)
A negative value for scaleFactor indicates
that the precision reduction will eliminate significant digits
to the left of the decimal point. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NumberPrecisionReducer
public NumberPrecisionReducer()
NumberPrecisionReducer
public NumberPrecisionReducer(double scaleFactor)
- A negative value for scaleFactor indicates
that the precision reduction will eliminate significant digits
to the left of the decimal point.
(I.e. the scale factor
will be divided rather than multiplied).
A zero value for scaleFactor will result in no precision reduction being performed.
A scale factor is normally an integer value.
- Parameters:
scaleFactor -
scaleFactorForDecimalPlaces
public static double scaleFactorForDecimalPlaces(int decimalPlaces)
- Computes the scale factor for a given number of decimal places.
A negative value for decimalPlaces indicates the scale factor
should be divided rather than multiplied. The negative sign
is carried through to the computed scale factor.
- Parameters:
decimalPlaces -
- Returns:
- the scale factor
setScaleFactor
public void setScaleFactor(double scaleFactor)
reducePrecision
public double reducePrecision(double d)