Tan of 90 in Google Chrome (JavaScript) -


when evaluate either of these statements in stable version of chrome (version 32.0.1700.107) value that's not infinity.

 math.tan(90 * math.pi / 180) 16331778728383844  math.tan(math.pi/2)  16331778728383844 

what root of problem? math.tan not reassigned new value elsewhere in code.

the rounding errors. same reason math.cos(math.pi/2) won't give 0.

update: gives 0 on latest version of chrome/node - judging open issue, it's considered regression in v8. still (and it's mentioned in issue's discussion), math.sin/cos implementation-dependent approximations, , expecting behave in uniform way across board is, sadly, overoptimistic.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -