Function to format a decimal point number in an integer, without
rounding.
The value must be a string made of ASCII digits, an optional leading
"-" and at most one "." or "," decimal separator, with at least one
digit. Surrounding whitespace is ignored. Fractional digits beyond
decimals are accepted only when they are zeros (the value is still
exact); any other excess digit throws, so that the amount shown to
the user is always the amount that gets encoded.
Throws
Error if the value is not a string in that format, cannot be
represented exactly with decimals decimals, or decimals is not a
non-negative integer.
Function to format a decimal point number in an integer, without rounding.
The value must be a string made of ASCII digits, an optional leading "-" and at most one "." or "," decimal separator, with at least one digit. Surrounding whitespace is ignored. Fractional digits beyond
decimalsare accepted only when they are zeros (the value is still exact); any other excess digit throws, so that the amount shown to the user is always the amount that gets encoded.Throws
Error if the value is not a string in that format, cannot be represented exactly with
decimalsdecimals, ordecimalsis not a non-negative integer.Example