incorrect result with Math.wrap()

Posted on
  • The result of Math.wrap(4,3) is 0.A. I assume this is a floating point bug of some sort?

  • Heh, yes. Sorry - I was actually trying to fix this last night.

    The artithmetic is absolutely fine - it's a bug in the float to string code. I was actually trying to fix this just yesterday, but I've added a bug for it to track it now: https://github.com/espruino/Espruino/issues/190

  • Thanks. I'll delve into the code myself some day so that I can help out in fixing these issues, but some day so far seems to have been a moving target ;).

    As for the fix, I assume you'll just need to use some threshold when converting floating points as you will never get a perfect mapping. I have some code that I wrote a while back for a similar issue, but I'll have to dig it up though ...

  • Hi Kim,

    Yes, I thought I'd used a threshold - but it turns out to be slightly more tricky than that (or I'm doing something very wrong!).

  • Seems to be fixe with 1.46 :). Do you collect any release notes on new versions?

  • Great! Info here:

    http://www.espruino.com/ChangeLog

    Yes, that is one of the things I fixed. It's not perfect IMO but it's an awful lot better :)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

incorrect result with Math.wrap()

Posted by Avatar for Kim @Kim

Actions