0.1 is exactly one tenth, and
1.1 + 2.2 is exactly 3.3. A value changes only at a round that the rater writes.
Why exact numbers matter
A rating manual prints its rates and factors as decimals. Most programs store numbers in binary, which holds most decimals only approximately. Over a long chain of factors, those small errors can move a premium by a cent. The result can also depend on the order of the steps. RSL keeps each value exact through the declared operations. The same implementation and inputs produce the same result across machines. Calculation order still matters where rounding intervenes. Validate the declared order and rounding rules against the filing and independent examples.Inputs arrive exactly
The rater reads each number in a request from its text, so1000.005 stays 1000.005. It then
checks the number against its declared precision, and refuses a number off that precision:
relativities-examples/rsl/exact:
- Send numbers as JSON numbers. A number inside a string is a type error.
- An exponent such as
1e3is fine, because it names an exact value. - The rater uses each input as sent. Round an input before you send it.
Division keeps the exact value
1000 / 12 is exactly 250/3, and the calculation keeps that value until a round:
250/3, comes back as {"$rational": "p/q"}. A premium always rounds, so it always comes back
as a decimal.
A precision on a calculation is a promise
A calculation typed with a precision, such asMoney in whole cents, promises values on that
precision. The check proves the promise, and the rater rounds only where a round says so.
What rslc checks and guarantees shows the message for a
broken promise.
Related
- Round a premium shows each rounding mode.