final class Quantity[N, U] extends AnyVal with Serializable
A numeric quantity with an associated unit
- N
The value type (Double, Int, etc)
- U
The unit type (Second, Byte, Byte %/ Second, etc)
- Alphabetic
- By Inheritance
- Quantity
- Serializable
- AnyVal
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new Quantity(value: N)
- value
the raw (unitless) value stored by this quantity
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- Any
- final def ##: Int
- Definition Classes
- Any
- def *[N2, U2](rhs: Quantity[N2, U2])(implicit um: UnitMul[N, U, N2, U2]): Quantity[N, RT]
Compute the product of two quantities
Compute the product of two quantities
- N2
the value type of the rhs quantity
- U2
the unit type of the rhs quantity.
- rhs
the right hand quantity in the product.
- returns
this*rhs, with value type N and unit type U*U2.
- def +[N2, U2](rhs: Quantity[N2, U2])(implicit ua: UnitAdd[N, U, N2, U2]): Quantity[N, U]
Compute the sum of two quantities
Compute the sum of two quantities
- N2
the value type of the rhs quantity
- U2
the unit type of the rhs quantity. Must be convertable to U, or a compile-time type error will result.
- rhs
the right hand quantity in the sum.
- returns
this+rhs, expressed in units (N,U).
- def -[N2, U2](rhs: Quantity[N2, U2])(implicit us: UnitSub[N, U, N2, U2]): Quantity[N, U]
Compute the difference of two quantities
Compute the difference of two quantities
- N2
the value type of the rhs quantity
- U2
the unit type of the rhs quantity. Must be convertable to U, or a compile-time type error will result.
- rhs
the right hand quantity in the difference.
- returns
this-rhs, expressed in units (N,U).
- def /[N2, U2](rhs: Quantity[N2, U2])(implicit ud: UnitDiv[N, U, N2, U2]): Quantity[N, RT]
Divide this quantity by another
Divide this quantity by another
- N2
the value type of the rhs quantity
- U2
the unit type of the rhs quantity.
- rhs
the right hand quantity.
- returns
this/rhs, with value type N and unit type U/U2.
- def <[N2, U2](rhs: Quantity[N2, U2])(implicit uc: UnitOrd[N, U, N2, U2]): Boolean
Test if this quantity is less than another
Test if this quantity is less than another
- N2
the value type of the rhs quantity
- U2
the unit type of the rhs quantity. Must be convertable to U, or a compile-time type error will result.
- rhs
the right hand quantity.
- returns
true if this quantity is less than the right quantity (after conversion to types N,U), false otherwise
- def <=[N2, U2](rhs: Quantity[N2, U2])(implicit uc: UnitOrd[N, U, N2, U2]): Boolean
Test if this quantity is less than or equal to another
Test if this quantity is less than or equal to another
- N2
the value type of the rhs quantity
- U2
the unit type of the rhs quantity. Must be convertable to U, or a compile-time type error will result.
- rhs
the right hand quantity.
- returns
true if this quantity is less than or equal to the right quantity (after conversion to types N,U), false otherwise
- def =!=[N2, U2](rhs: Quantity[N2, U2])(implicit uc: UnitOrd[N, U, N2, U2]): Boolean
Test if two quantities are not equal
Test if two quantities are not equal
- N2
the value type of the rhs quantity
- U2
the unit type of the rhs quantity. Must be convertable to U, or a compile-time type error will result.
- rhs
the right hand quantity.
- returns
true if rhs is not equal to this quantity (after conversion to types N,U), false otherwise
- final def ==(arg0: Any): Boolean
- Definition Classes
- Any
- def ===[N2, U2](rhs: Quantity[N2, U2])(implicit uc: UnitOrd[N, U, N2, U2]): Boolean
Test if two quantities are equal
Test if two quantities are equal
- N2
the value type of the rhs quantity
- U2
the unit type of the rhs quantity. Must be convertable to U, or a compile-time type error will result.
- rhs
the right hand quantity.
- returns
true if rhs is equal to this quantity (after conversion to types N,U), false otherwise
- def >[N2, U2](rhs: Quantity[N2, U2])(implicit uc: UnitOrd[N, U, N2, U2]): Boolean
Test if this quantity is greater than another
Test if this quantity is greater than another
- N2
the value type of the rhs quantity
- U2
the unit type of the rhs quantity. Must be convertable to U, or a compile-time type error will result.
- rhs
the right hand quantity.
- returns
true if this quantity is greater than the right quantity (after conversion to types N,U), false otherwise
- def >=[N2, U2](rhs: Quantity[N2, U2])(implicit uc: UnitOrd[N, U, N2, U2]): Boolean
Test if this quantity is greater than or equal to another
Test if this quantity is greater than or equal to another
- N2
the value type of the rhs quantity
- U2
the unit type of the rhs quantity. Must be convertable to U, or a compile-time type error will result.
- rhs
the right hand quantity.
- returns
true if this quantity is greater than or equal to the right quantity (after conversion to types N,U), false otherwise
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def pow[P](implicit up: UnitPow[N, U, P]): Quantity[N, RT]
Raise this quantity to an integer power
Raise this quantity to an integer power
- P
the literal type representing the integer exponent
- returns
this quantity raised to power P, with unit type U^P
- def show(implicit ustr: UnitString[U]): String
A string representation of this quantity, using unit abbreviations
- def showFull(implicit ustr: UnitString[U]): String
A string representation of this quantity, using full unit names
- def showUnit(implicit ustr: UnitString[U]): String
A string representation of this quantity's associated unit, using abbreviations
- def showUnitFull(implicit ustr: UnitString[U]): String
A String representation of this quantity's associated unit, using full names
- def to[N2, U2](implicit uc: UnitConverter[N, U, N2, U2]): Quantity[N2, U2]
Equivalent to this.toUnit[U2].toValue[N2]
Equivalent to this.toUnit[U2].toValue[N2]
- N2
the value type to convert to.
- U2
the new units to convert to. Must be convertable to U, or a compile-time type error will result.
- returns
a quantity equivalent to this but with value type N2 and units U2
- def toString(): String
- Definition Classes
- Quantity → Any
- def toUnit[U2](implicit uc: UnitConverter[N, U, N, U2]): Quantity[N, U2]
Obtain a quantity that is equivalent to this but with different compatible units
Obtain a quantity that is equivalent to this but with different compatible units
- U2
the new units to convert to. Must be convertable to U, or a compile-time type error will result.
- returns
a quantity equivalent to this, but with units U2
- def toValue[N2](implicit uc: UnitConverter[N, U, N2, U]): Quantity[N2, U]
Obtain a quantity equivalent to this but with a different value type
Obtain a quantity equivalent to this but with a different value type
- N2
the value type to convert to.
- returns
a quantity equivalent to this but with value type N2 and units U
- def unary_-(implicit n: UnitNeg[N]): Quantity[N, U]
Obtain a quantity with the same unit but negated numeric value
- val value: N