Package hec.data
Class UsgsRounder
java.lang.Object
hec.data.UsgsRounder
Provides functionality of USGS rounding arrays (called rounding specifications in this package).
The full description of using rounding arrays can be found in Section 3.5 (Data Rounding Convention) of the
ADAPS Section of the National Water Information System User's Manual.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionformat
(double value) Formats a single value according to the rounding specificationString[]
format
(double[] values) Formats an array of values according to the rounding specificationstatic UsgsRounder
int
Retrieves the maximum number of decimal places for the specificationRetrieves the rounding specificationint[]
Retrieves the array of significant digits for the specificationdouble
round
(double value) Rounds a single value according to the rounding specificationdouble[]
round
(double[] values) Rounds an array of values according to the rounding specificationdouble[]
round
(double[] values, boolean roundHalfEven) Rounds an array of values according to the rounding specificationdouble
round
(double value, boolean roundHalfEven) Rounds a single value according to the rounding specificationvoid
setMaxDecimalPlaces
(int maxDecimalPlaces) Sets the maximum number of decimal places for the specification.void
setRoundingSpec
(CharSequence roundingSpec) Sets the rounding specificationvoid
setSignificantDigits
(int[] significantDigits) Sets the array of significant digits for the specification.toString()
-
Constructor Details
-
UsgsRounder
Public Constructor- Parameters:
roundingSpec
- The USGS-style rounding specification. This is a sting comprised of 10 digits.- Throws:
RoundingException
-
-
Method Details
-
getDefault
-
round
Rounds a single value according to the rounding specification- Parameters:
value
- The value to round- Returns:
- The value, rounded according to the specification
- Throws:
RoundingException
-
round
Rounds a single value according to the rounding specification- Parameters:
value
- The value to roundroundHalfEven
- Specifies whether .5 should be rounded to nearest even integer (true) or rounded away from zero (false)- Returns:
- The value, rounded according to the specification
- Throws:
RoundingException
-
round
Rounds an array of values according to the rounding specification- Parameters:
values
- The values to round- Returns:
- A copy of the input values, rounded according to the specification
- Throws:
RoundingException
-
round
Rounds an array of values according to the rounding specification- Parameters:
values
- The values to roundroundHalfEven
- Specifies whether .5 should be rounded to nearest even integer (true) or rounded away from zero (false)- Returns:
- A copy of the input values, rounded according to the specification
- Throws:
RoundingException
-
format
Formats a single value according to the rounding specification- Parameters:
value
- The value to format- Returns:
- The value, formatted according to the specification
- Throws:
RoundingException
-
format
Formats an array of values according to the rounding specification- Parameters:
values
- The values to format- Returns:
- Representations of the input values, formatted according to the specification
- Throws:
RoundingException
-
getSignificantDigits
public int[] getSignificantDigits()Retrieves the array of significant digits for the specification- Returns:
-
setSignificantDigits
Sets the array of significant digits for the specification.- Parameters:
significantDigits
- The array of significant digits. Must be a nine element array with each element in the range 0..9.- Throws:
RoundingException
-
getMaxDecimalPlaces
public int getMaxDecimalPlaces()Retrieves the maximum number of decimal places for the specification- Returns:
- The maximum number of decimal places
-
setMaxDecimalPlaces
Sets the maximum number of decimal places for the specification.- Parameters:
maxDecimalPlaces
- The maximum number of decimal places. Must be in the range 0..9- Throws:
RoundingException
-
getRoundingSpec
Retrieves the rounding specification- Returns:
- The rounding specification
-
setRoundingSpec
Sets the rounding specification- Parameters:
roundingSpec
- The USGS-style rounding specification. This is a sting comprised of 10 digits.- Throws:
RoundingException
-
toString
-