archives

« Bugzilla Issues Index

#285 — S15.8.2.16_A7 & S15.8.2.18_A7 (sin & tan) overconstrain implementations


The test S15.8.2.16_A7 checks whether (within a certain tolerance)

sin(6.283185307179586) == -2.4492935982947064e-16

The argument is very close to 2*pi, and sin(2*pi) = 0. Usual algorithms for sine have low precision at this point. Both Firefox and Chrome fail in this test on Linux but succeed on Windows and Mac OS X because the value of the sine function depends on compiler/platform. An arbitrary-precision calculator like bc or Wolfram Alpha returns approximately 4.7692E-16, which would fail the test, too.

Likewise, S15.8.2.18_A7 tests whether (within a certain tolerance)

tan(-1.57079632679489660000) == -16331239353195370.00000000000000000000

The argument is very close to pi/2, around which tangens is an unstable function. On IA32, both the FPU instruction and the library function for tangent use 80-bit precision provided by the FPU, which results in -16331778728383844, which is outside the tolerated range. This can also be observed on 32-bit Firefox on Linux, which suffers from the same problem and can be circumvented when compiling with -ffloat-store. With an arbitrary-precision calculator, the result is approximately -5.19985E16.

The spec (15.8.2.18) allows implementation-dependent approximations of transcendental functions. These tests should therefore not test locally unstable functions against the result of any particular implementation, much less one that is not accurate to begin with. (In effect, test262 _disallows_ a more accurate approximation.)


This is a duplicate of https://bugs.ecmascript.org/show_bug.cgi?id=126 which TC-39 made a call to "Won't Fix".

If you can give me a looser "prec" value (see bug 126) that causes these tests to pass in your scenarios, I'd be more than happy to make the change though:)