firmata / firmata.js

JavaScript implementation of the Firmata protocol
711 stars 147 forks source link

encodeCustomFloat: "must encode custom floats when they are less than 1" is failing #209

Open rwaldron opened 4 years ago

rwaldron commented 4 years ago

@dtex I don't understand this failure :|

1) Numeric encoding/decoding and formatting
       must encode custom floats when they are less than 1:

      AssertionError: expected Array [ 69, 2, 0, 20 ] deepEqual Array [ 79, 46, 70, 5 ]
      + expected - actual

       [
      -  69
      -  2
      -  0
      -  20
      +  79
      +  46
      +  70
      +  5
       ]
rwaldron commented 4 years ago

This appears to only occur locally for me 🤷🏼‍♂️

dtex commented 4 years ago

I'm able to replicate in node 12, but works fine in node 10. I can't imagine what has changed but I'll dig into it.

dtex commented 4 years ago

Tired: Off by 1 errors Wired: Off by 0.00000000000000000001 errors

Here's the scoop:

In node 10:

Math.pow(10, -4) === 0.0001

but in node 12

Math.pow(10, -4) === 0.00009999999999999999

Appears to be this issue which will be fixed by this commit and will eventually make its way to node.js. If we need to, we can comment out that test for now, or we could just leave this issue open and findable until node has the corrected version of v8.

rwaldron commented 4 years ago

Thanks for checking into that! I say we take no action on our end and leave this open for folks to easily find.