-
-
Converts this Quantity to another Quantity in the given
units or System.
`newUnits` may be the name of a defined Unit, the name of
a defined System, an instance of Unit, or an instance of
System.
This method provides an OO-flavored API that directly
corresponds to the Functional-flavored `Sr.convert(quantity, targetUnitsOrSystem)`.
-
-
Divides this Quantity by another Quantity and returns
the result as a new Quantity.
No unit conversion is performed on the divisor `rhs`.
Parameters:
Name |
Type |
Description |
rhs |
Quantity
|
the Quantity by which to divide this Quantity. |
-
-
Subtracts another Quantity from this Quantity and returns
the result as a new Quantity.
If the subtractend `rhs` is not expressed in the same units as this Quantity,
`rhs` will be converted to the same units as this Quantity.
If `rhs` cannot be converted to the same units as this Quantity,
(because, say, the Quantities are not dimensionally compatible)
an Error is thrown.
Parameters:
Name |
Type |
Description |
rhs |
Quantity
|
a dimensionally-compatible Quantity to subtract from this Quantity. |
-
-
Adds another Quantity to this Quantity and returns
the result as a new Quantity.
If the addend `rhs` is not expressed in the same units as this Quantity,
`rhs` will be converted to the same units as this Quantity.
If `rhs` cannot be converted to the same units as this Quantity,
(because, say, the Quantities are not dimensionally compatible)
an Error is thrown.
Parameters:
Name |
Type |
Description |
rhs |
Quantity
|
a dimensionally-compatible Quantity to add to this Quantity. |
-
-
Multiplies this Quantity by another Quantity and returns
the result as a new Quantity.
No unit conversion is performed on the multiplicand `rhs`.
Parameters:
Name |
Type |
Description |
rhs |
Quantity
|
the Quantity by which to multiply this Quantity. |
-
-
Returns a string representation of this Quantity,
including the `value()` and the symbolic representation
of `expression()`.
For instance, a Quantity representing "four meters"
will be rendered "4m".
Returns:
string
-
-
Returns the UnitExpression associated with this Quantity.
For example, given a Quantity representing "four meters per second",
this method returns a UnitExpression representing "meters per second."
-
-
Returns the scalar value associated with this Quantity.
For example, given a Quantity representing "four meters per second",
this method returns the number 4.
Returns:
number