You are reading a single comment by @charlie and its replies. Click here to read the full conversation.
  • I have added a round function to my code libs to round numbers to a certain number of decimals. It looks roughly as follows;

    const round = (numberToRound,decimalPlaces = 2) => (e => Math.round(numberToRound * e) / e)(Math.pow(10,decimalPlaces ));

    expected outcome:

    round(6800971.33999999985) = 6800971.34

    This passes all local unit tests compiling in es5, es6 and esnext. It also works fine on a couple of online javascript compilers I tested (codepen, Typescript playground) - and its exact copy of code others have used for doing the same thing.

    If I run this code on the bangle emulator or the bangle2 watch directly I get "NaN" returned.


Avatar for charlie @charlie started