archives

« Bugzilla Issues Index

#2580 — Why does Math.hypot(Infinity,NaN) return Infinity?


https://bugs.webkit.org/show_bug.cgi?id=129486 asks why the Math.hypot spec. says:

If any argument is +Infinity, the result is +Infinity.
If any argument is -Infinity, the result is +Infinity.
If no argument is +Infinity or -Infinity, and any argument is NaN, the result is NaN.

this seems to be what C libraries do:

http://pubs.opengroup.org/onlinepubs/009696799/functions/hypot.html
http://man7.org/linux/man-pages/man3/hypot.3.html

and is (according to Wikipedia) what the IEEE spec requires:
http://en.wikipedia.org/wiki/NaN#Function_definition