Math.sin () gives different results on server / client?

I use Meteor. It uses Javascript both on the server and on the client.

When I run Math.sin(356644061314425) * 10000 , I get:

-9986.46139381927 on the server and

-9986.46115497749 on the client / browser / application

Why is this? How can I prevent this?

EDIT: Suggested duplicate questions refer to degrees / radian. I believe that my problem is more time.

+6
source share
1 answer

I think the answer to the question "How can I prevent this?" "You can not".

The answer to the question "Why is this?" that javascript implementation of Math.sin is undefined.

See http://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.16

In particular, "sin (x) Returns an implementation-dependent approximation to the sine of x. The argument is expressed in radians." (italics mine).

But my experiments show that modern browsers currently use only one of two implementations, with Chrome different (and, apparently, more accurate than) other browsers.

+6
source

All Articles