uncertaintyRangeForQuantity function

QuantityRange<Quantity> uncertaintyRangeForQuantity(
  1. Quantity q, {
  2. double k = 1.0,
})

Creates a QuantityRange that represents the standard uncertainty of q.

Implementation

QuantityRange<Quantity> uncertaintyRangeForQuantity(Quantity q,
    {double k = 1.0}) {
  final std = q.standardUncertainty;
  if (k == 1.0) {
    return QuantityRange<Quantity>(q - std, q + std);
  } else {
    final expanded = q.calcExpandedUncertainty(k);
    return QuantityRange<Quantity>(q - expanded, q + expanded);
  }
}