Today when you make a Birt report, you want to display a list of percentages of data, but for some special reasons, you cannot use the percent style, which means that if the data is 0.9538, it cannot be displayed as a "95.38%" style and must be displayed as "95.38".
To start with JavaScript's built-in function, Math.Round (), Math.Round () can only be displayed as integers, not decimals.
Again online search, or use Math.Round (), written math.round (x*100)/100, of course I want to Math.Round (x*100), it does not matter. But the direct use of Math.Round (x*100) There is a problem, sometimes there is a small error, showing a lot of bits of the decimal place, such as 0.9996*100, will become 99.96000000000001, this is not what I want.
To find the functionality of JavaScript, the number type has a tofixed () function, which tests:
Alert ((0.9996*100). toFixed (2));
Get 99.96, this is what I want!
Use Number.tofixed () to display any number of decimal digits in the format numbers!
JS reserved two decimal places