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???
toFixed()
Math.round()
2 Attachments
@Robin started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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:
Interactive fiddle Demo
Tried it out in Chrome browser
Now we are on the right track, or are we???
Test using Espruino WebIDE
And, SURPRISE!! that failed. Is it the
toFixed()
or the actualMath.round()
this time???2 Attachments