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


i use meteor. uses javascript on both server , client.

when run math.sin(356644061314425) * 10000 get:

-9986.46139381927 on server and

-9986.46115497749 on client / browser / app

why this? how can prevent this?

edit: proposed duplicate questions refer degrees / radians. think mine more runtime problem.

i think answer "how prevent this?" "you can't".

the answer "why this?" javascript implementation of math.sin not determined.

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

specifically "sin (x) returns implementation-dependent approximation sine of x. argument expressed in radians." (my italics).

but experimentation suggests modern browsers use 1 of 2 implementations, chrome being different (and seemingly more accurate than) other browsers.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -