NOTE: The other file in the gist shows the same but using "significant digits" rather than "fractional digits". After trying to use it, I noticed that almost always we want to start counting fro mthe units and not from the most significant digit.
A "numeric with precision" is a pair consisting of a numeric value and an indication of how many of its digits are significant. The number of digits is counted starting from the units: 1
means the first digit after the dot, 0
means that we have an integer, -1
means that we have a multiple of 10.
It can be obtained from a numeric value (wether it's decimal, float, or bigint) by "decorating it":
new Decimal("123.45").withFractionalDigits(1);
123.45.withFractionalDigits(1);