Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

two decimal places in javascript

Number(1).toFixed(2);         // 1.00
Number(1.341).toFixed(2);     // 1.34
Number(1.345).toFixed(2);     // 1.34 NOTE: See andy's comment below.
Number(1.3450001).toFixed(2); // 1.35
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #decimal #places #javascript
ADD COMMENT
Topic
Name
2+5 =