Quantity
Defines Quantity constructors and extension methods
Attributes
- Source:
- quantity.scala
- Graph
- Supertypes
- Self type
- Quantity.type
Members list
Type members
Classlikes
A shim class for Quantity companion object constructors
A shim class for Quantity companion object constructors
Attributes
- Companion:
- object
- Source:
- quantity.scala
- Graph
- Supertypes
Attributes
- Companion:
- class
- Source:
- quantity.scala
- Graph
- Supertypes
- Self type
- Applier.type
Value members
Extensions
Extensions
multiply this quantity by another
multiply this quantity by another
Attributes
- UR
right hand unit type
- VR
right hand value type
- qr
right hand quantity
- Returns:
the product of this quantity with
qr
- Note:
result may depend on what algebras, policies, and other typeclasses are in scope
- Example:
val q1 = 2.withUnit[Meter] val q2 = (3.0).withUnit[Meter] q1 * q2 // => Quantity[Meter ^ 2](6.0)
- Source:
- quantity.scala
add this quantity to another
add this quantity to another
Attributes
- UR
right hand unit type
- VR
right hand value type
- qr
right hand quantity
- Returns:
the sum of this quantity with
qr
- Note:
unit types
UL
andUR
must be convertableresult may depend on what algebras, policies, and other typeclasses are in scope
- Example:
val q1 = 1.withUnit[Meter] val q2 = (1.0).withUnit[Yard] q1 + q2 // => Quantity[Meter](1.9144)
- Source:
- quantity.scala
subtract another quantity from this one
subtract another quantity from this one
Attributes
- UR
right hand unit type
- VR
right hand value type
- qr
right hand quantity
- Returns:
the result of subtracting
qr
from this- Note:
unit types
UL
andUR
must be convertableresult may depend on what algebras, policies, and other typeclasses are in scope
- Example:
val q1 = 1.withUnit[Meter] val q2 = (1.0).withUnit[Yard] q1 - q2 // => Quantity[Meter](0.0856)
- Source:
- quantity.scala
divide this quantity by another
divide this quantity by another
Attributes
- UR
right hand unit type
- VR
right hand value type
- qr
right hand quantity
- Returns:
the quotient of this quantity with
qr
- Note:
result may depend on what algebras, policies, and other typeclasses are in scope
- Example:
val q1 = 3.withUnit[Meter] val q2 = (2.0).withUnit[Second] q1 / q2 // => Quantity[Meter / Second](1.5)
- Source:
- quantity.scala
test if this quantity is less than another
test if this quantity is less than another
Attributes
- UR
unit type of the right hand quantity
- VR
value type of the right hand quantity
- qr
the right hand quantity
- Returns:
true if left-hand value is less than the right (after any conversions), false otherwise
- Note:
result may depend on what algebras, policies, and other typeclasses are in scope
- Example:
val q1 = 1000.withUnit[Liter] val q2 = (2.0).withUnit[Meter ^ 3] q1 < q2 // => true
- Source:
- quantity.scala
test if this quantity is less than or equal to another
test if this quantity is less than or equal to another
Attributes
- UR
unit type of the right hand quantity
- VR
value type of the right hand quantity
- qr
the right hand quantity
- Returns:
true if left-hand value is less than or equal to the right (after any conversions), false otherwise
- Note:
result may depend on what algebras, policies, and other typeclasses are in scope
- Example:
val q1 = 1000.withUnit[Liter] val q2 = (2.0).withUnit[Meter ^ 3] q1 <= q2 // => true
- Source:
- quantity.scala
test this quantity for inequality with another
test this quantity for inequality with another
Attributes
- UR
unit type of the right hand quantity
- VR
value type of the right hand quantity
- qr
the right hand quantity
- Returns:
true if right hand value does not equal left (after any conversions), false otherwise
- Note:
result may depend on what algebras, policies, and other typeclasses are in scope
- Example:
val q1 = 1000.withUnit[Liter] val q2 = (2.0).withUnit[Meter ^ 3] q1 =!= q2 // => true
- Source:
- quantity.scala
test this quantity for equality with another
test this quantity for equality with another
Attributes
- UR
unit type of the right hand quantity
- VR
value type of the right hand quantity
- qr
the right hand quantity
- Returns:
true if right hand value equals the left (after any conversions), false otherwise
- Note:
result may depend on what algebras, policies, and other typeclasses are in scope
- Example:
val q1 = 1000.withUnit[Liter] val q2 = (1.0).withUnit[Meter ^ 3] q1 === q2 // => true
- Source:
- quantity.scala
test if this quantity is greater than another
test if this quantity is greater than another
Attributes
- UR
unit type of the right hand quantity
- VR
value type of the right hand quantity
- qr
the right hand quantity
- Returns:
true if left-hand value is greater than the right (after any conversions), false otherwise
- Note:
result may depend on what algebras, policies, and other typeclasses are in scope
- Example:
val q1 = 2000.withUnit[Liter] val q2 = (1.0).withUnit[Meter ^ 3] q1 > q2 // => true
- Source:
- quantity.scala
test if this quantity is greater than or equal to another
test if this quantity is greater than or equal to another
Attributes
- UR
unit type of the right hand quantity
- VR
value type of the right hand quantity
- qr
the right hand quantity
- Returns:
true if left-hand value is greater than or equal to the right (after any conversions), false otherwise
- Note:
result may depend on what algebras, policies, and other typeclasses are in scope
- Example:
val q1 = 2000.withUnit[Liter] val q2 = (1.0).withUnit[Meter ^ 3] q1 >= q2 // => true
- Source:
- quantity.scala
raise this quantity to a rational or integer power
raise this quantity to a rational or integer power
Attributes
- P
the power, or exponent
- Returns:
this quantity raised to exponent
P
- Example:
val q = (2.0).withUnit[Meter] q.pow[2] // => Quantity[Meter ^ 2](4.0) q.pow[1/2] // => Quantity[Meter ^ (1/2)](1.4142135623730951) q.pow[-1] // => Quantity[1 / Meter](0.5)
- Source:
- quantity.scala
returns a string representing this Quantity, using unit abbreviations
returns a string representing this Quantity, using unit abbreviations
Attributes
- Example:
val q = (1.5).withUnit[Meter / Second] q.show // => "1.5 m/s"
- Source:
- quantity.scala
returns a string representing this Quantity, using full unit names
returns a string representing this Quantity, using full unit names
Attributes
- Example:
val q = (1.5).withUnit[Meter / Second] q.showFull // => "1.5 meter/second"
- Source:
- quantity.scala
convert a quantity to a new unit type, using an integral value type
convert a quantity to a new unit type, using an integral value type
Attributes
- U
the new unit type
- Returns:
a new
Quantity
having unit typeU
- Note:
attempting to convert to an incompatible unit will result in a compile error
- Example:
val q = 10.withUnit[Yard] q.tToUnit[Meter] // => Quantity[Meter](9)
- Source:
- quantity.scala
convert a quantity to an integer value type from a fractional type
convert a quantity to an integer value type from a fractional type
Attributes
- V
a new integral value type
- Returns:
a new
Quantity
having value typeV
- Example:
val q = (1.0).withUnit[Meter] q.tToUnit[Long] // => Quantity[Meter](1L)
- Source:
- quantity.scala
convert a quantity to a new unit type
convert a quantity to a new unit type
Attributes
- U
the new unit type
- Returns:
a new
Quantity
having unit typeU
- Note:
attempting to convert to an incompatible unit will result in a compile error
- Example:
val q = (1.0).withUnit[Meter ^ 3] q.toUnit[Liter] // => Quantity[Liter](1000.0) q.toUnit[Hectare] // => compile error
- Source:
- quantity.scala
convert a quantity to a new value type
convert a quantity to a new value type
Attributes
- V
the new value type to use
- Returns:
a new
Quantity
having value typeV
- Example:
val q = (1.0).withUnit[Meter] q.toValue[Float] // => Quantity[Meter](1.0f)
- Source:
- quantity.scala
raise this quantity to a rational or integer power, with integer truncated result
raise this quantity to a rational or integer power, with integer truncated result
Attributes
- P
the power, or exponent
- Returns:
this quantity raised to exponent
P
, truncated to integer type- Example:
val q = 10.withUnit[Meter] q.tpow[2] // => Quantity[Meter ^ 2](100) q.tpow[1/2] // => Quantity[Meter ^ (1/2)](3) q.tpow[-1] // => Quantity[1 / Meter](0)
- Source:
- quantity.scala
divide this quantity by another, using truncating (integer) division
divide this quantity by another, using truncating (integer) division
Attributes
- UR
right hand unit type
- VR
right hand value type
- qr
right hand quantity
- Returns:
the integral quotient of this quantity with
qr
- Note:
result may depend on what algebras, policies, and other typeclasses are in scope
- Example:
val q1 = 5.withUnit[Meter] val q2 = 2L.withUnit[Second] q1.tquot(q2) // => Quantity[Meter / Second](2L)
- Source:
- quantity.scala
negate the value of a Quantity
negate the value of a Quantity
Attributes
- Returns:
a
Quantity
having the negative of the original value- Example:
val q = 1.withUnit[Meter] -q // => Quantity[Meter](-1)
- Source:
- quantity.scala
extract the raw value of a unit quantity
extract the raw value of a unit quantity
Attributes
- Returns:
the underlying value, stripped of its unit information
val q = (1.5).withUnit[Meter] q.value // => 1.5
- Source:
- quantity.scala