Ok dumb question (Wappler newb here)
In the data formatter, how do I format a decimal number so there are only 2 places after the decimal? Example return 1.99 instead of 1.999999999999998
Ok dumb question (Wappler newb here)
In the data formatter, how do I format a decimal number so there are only 2 places after the decimal? Example return 1.99 instead of 1.999999999999998
There is a formatNumber and round formatter, but they will round the number and not strip off like in your example. So 1.999999999999998
would become 2.00
and 1.992345
would become 1.99
.
(1.999999999999998).round(2)
will round on 2 decimals and returns a number
(1.999999999999998).formatNumber(2)
will also round on 2 decimals and returns a string, you can also change the separator and delimiter, so an expression like (1250.1234).formatNumber(2, ',', '.')
will output 1.250,12
as a string.
@Patrick Thank you!