• The result of toFixed looks like a number, because you console.log it, so there are no parenthesis around the printed value.

    >var fixed = kwh.toFixed(2);
    ="1234.50"
    
    >typeof fixed
    ="string"
    

    And yes, looks like some rounding anomaly:

    >2134.506.toFixed(2)
    ="2134.50"
    >2134.507.toFixed(2)
    ="2134.51"
    
  • Our posts are crossing each other and I hadn't finalized that post. Discovered the difference while ping-ponging between MDN and the WebIDE. Is an interesting subtlety one needs to be aware of. Thanks for confirming.

    'so there are no parenthesis '    (double quotes)

    May I inquire as to which Espruino version those tests were done? (same 2v04 ?)


    Had a thought, could this anomaly be related to the floating point number of digits to right of zero not matching different browsers and node.js output? hmmmm. . . .

    http://forum.espruino.com/conversations/­336605/
    test files #1

About

Avatar for Robin @Robin started