| javax.measure.DecimalMeasure
DecimalMeasure | public class DecimalMeasure extends Measure (Code) | | This class represents a measure whose value is an arbitrary-precision
decimal number.
When converting, applications may supply the
java.math.Context :[code]
DecimalMeasure c = DecimalMeasure.valueOf("299792458 m/s");
DecimalMeasure milesPerHour = c.to(MILES_PER_HOUR, MathContext.DECIMAL128);
System.out.println(milesPerHour);
> 670616629.3843951324266284896206156 mph
[/code]
author: Jean-Marie Dautelle version: 4.3, October 3, 2007 |
Constructor Summary | |
public | DecimalMeasure(BigDecimal value, Unit<Q> unit) Creates a decimal measure for the specified number stated in the
specified unit. |
Method Summary | |
public double | doubleValue(Unit<Q> unit) | public Unit<Q> | getUnit() | public BigDecimal | getValue() | public DecimalMeasure<Q> | to(Unit<Q> unit) Returns the decimal measure equivalent to this measure but stated in the
specified unit. | public DecimalMeasure<Q> | to(Unit<Q> unit, MathContext mathContext) Returns the decimal measure equivalent to this measure but stated in the
specified unit, the conversion is performed using the specified math
context.
Parameters: unit - the new measurement unit. Parameters: mathContext - the mathContext used to convert BigDecimal values or null if none. | public static DecimalMeasure<Q> | valueOf(BigDecimal decimal, Unit<Q> unit) Returns the decimal measure for the specified number stated in the
specified unit. | public static DecimalMeasure<Q> | valueOf(CharSequence csq) Returns the decimal measure for the specified textual representation. |
DecimalMeasure | public DecimalMeasure(BigDecimal value, Unit<Q> unit)(Code) | | Creates a decimal measure for the specified number stated in the
specified unit.
|
doubleValue | public double doubleValue(Unit<Q> unit)(Code) | | |
to | public DecimalMeasure<Q> to(Unit<Q> unit)(Code) | | Returns the decimal measure equivalent to this measure but stated in the
specified unit. This method will raise an ArithmeticException if the
resulting measure does not have a terminating decimal expansion.
Parameters: unit - the new measurement unit. the measure stated in the specified unit. throws: ArithmeticException - if the converted measure value does not havea terminating decimal expansion See Also: DecimalMeasure.to(Unit,MathContext) |
to | public DecimalMeasure<Q> to(Unit<Q> unit, MathContext mathContext)(Code) | | Returns the decimal measure equivalent to this measure but stated in the
specified unit, the conversion is performed using the specified math
context.
Parameters: unit - the new measurement unit. Parameters: mathContext - the mathContext used to convert BigDecimal values or null if none. the measure stated in the specified unit. throws: ArithmeticException - if the result is inexact but therounding mode is MathContext.UNNECESSARY or mathContext.precision == 0 and the quotient has a non-terminating decimal expansion. |
valueOf | public static DecimalMeasure<Q> valueOf(BigDecimal decimal, Unit<Q> unit)(Code) | | Returns the decimal measure for the specified number stated in the
specified unit.
Parameters: decimal - the measurement value. Parameters: unit - the measurement unit. |
valueOf | public static DecimalMeasure<Q> valueOf(CharSequence csq)(Code) | | Returns the decimal measure for the specified textual representation.
This method first reads the BigDecimal value, then
the unit if any (value and unit should be separated by white spaces).
Parameters: csq - the decimal measure representation (including unit if any). throws: NumberFormatException - if the specified character sequence is not a valid representation of decimal measure. |
|
|