Use decimal
s, not double
s
Floating point numbers, i.e. float
and double
, are the result of a trade-off between numerical precision and computation time.
While great in many applications, we opted not to support them in Nancy to prevent their approximation errors from propagating through our algorithms.
Still, you will often want to write literals as a starting point in your code.
To do this, you can use decimal
s by just appending an m
to the right.
var a = new RateLatencyServiceCurve(4, 0.5); // double, will not compile
var a = new RateLatencyServiceCurve(4, 0.5m); // decimal, ok
A decimal
is a precise representation which will be translated, without any loss of accuracy, into a Rational
with as its denominator.