format - number of decimal digits
I'm busy with a first attempt using jsreport for an invoice-kind of report. At the end of the report I'm calculating the total.
(1) The sum sometimes has a small deviation. Example : 0.71 + 25.42 = 26.1300000000000000000003
(2) I would like to be able to control the output format of my numbers
(1) and (2) would be solved if i'm able to control the output format of my number ( let's say to 2 digits ). I'm new to jscript. I've been searching far an example or clue but without solution. Is there something out of the box I can use for number formatting or should I install an handlebars extension or ... ? ( on jsrender I found reference to .toFixed() but couldn't get this implemented )
An example of my report can be found at :
i think you can solve this with the .toFixed or by searching out there some logic to format the number, i did a search and found this. so i have updated your example with the usage of the two ways: https://playground.jsreport.net/w/bjrmatos/_eOIhKye
between the two, the
numberFormathelper is better because it offers some customization options for the decimals and the separators.