operator * method
Returns the product of this quantity and multiplier
, which is expected
to be either a Quantity, num or Number object. All other
types will cause a QuantityException to be thrown.
- This Quantity object is unaffected.
- The uncertainty of the resulting product Quantity is equal to the relative combined standard uncertainty, defined as the square root of the sum of the squares of the two quantities' relative standard uncertainties.
Implementation
Quantity operator *(dynamic multiplier) {
if (multiplier is num || multiplier is Number) return this * Scalar(value: multiplier);
// Product uncertainty
var productUr = _ur;
// Product value
Number productValue;
// Product dimensions
var productDimensions = dimensions;
// Branch on Quantity, num, Number
if (multiplier is Quantity) {
final q2 = multiplier;
productDimensions = dimensions * q2.dimensions;
productValue = valueSI * q2.valueSI;
productUr = (_ur != 0.0 || q2._ur != 0.0) ? math.sqrt(_ur * _ur + q2._ur * q2._ur) : 0.0;
} else {
throw const QuantityException('Expected a Quantity, num or Number object');
}
if (dynamicQuantityTyping) {
return productDimensions.toQuantity(productValue, null, productUr);
} else {
return MiscQuantity(productValue, productDimensions, productUr);
}
}