• Mon 2019.08.26

    I'm so hoarse, can't be heard, so decided to create that patch 'fix' as suggested. Used the standard rounding function which is recognized by most:

    var roundedNum = ( Math.round( num * 100 )  /  100 ).toFixed( place );
    
    



    Interactive fiddle Demo

    http://jsfiddle.net/jfriend00/kvpgE/

    Tried it out in Chrome browser

    num= 1.005 place=2
    roundedNum= 1.00
    
    
    num= 1234.505 place=2
    roundedNum= 1234.51
    



    Now we are on the right track, or are we???

    Test using Espruino WebIDE

    num= 1.005  place=2
    roundedNum= 1.00
     
      
    num= 1234.505  place=2
    roundedNum= 1234.50
    



    And, SURPRISE!!   that failed. Is it the toFixed() or the actual Math.round() this time???


    2 Attachments

About

Avatar for Robin @Robin started