News for hackers. Stuff that matters.
Re:Adding BigInts to V8 by strainer on Wednesday May 02, 2018 @10:35PM (#16982950)
Epsilon is not the smallest quantity that can be represented. Its the smallest amount that can be added to a number between 1 and 2. If its added to 2 the result is 2. We need to add 2 * Number.EPSILON to 2 to add anything. 4 * E to 4, 8 * E to 8, 16 * E to 16 etc.

That kind of equality test should be:

  abs( a-b ) < Number.EPSILON * max( abs(a), abs(b) )
In practice I judge the scale of the quantization noise that may accrue and compare the difference to it.

It may also be possible to kind of caste precision away by adding a trick value. eg.

  a + t == b + t
If a and b are positive, that is somewhat similar to:

  abs( a-b ) < Number.EPSILON * t
Re:Adding BigInts to V8 by partycoder on Wednesday May 02, 2018 @11:03PM (#16983058)
Thanks for pointing it out.

A more popular definition is "the smallest number that yields a result different to 1 when added to 1".

Re:Adding BigInts to V8 by strainer on Thursday May 03, 2018 @11:51AM (#16987050)
Look out - I just now tested those two extra ideas which I added for equality testing and found they dont work.

This version of adding a rounding value seems to though:

  ( a-b + rounder ) == rounder
My apologies, be careful out there :)