In comp.lang.javascript message <847acf89-e72b-4803-8a18-daf70971713a@g1

7g2000prg.googlegroups.com>, Mon, 13 Oct 2008 17:52:16, RobG

<rg***@iinet.net.auposted:

>

ECMA-262 does not specify how Math functions are to be implemented,

although it suggests using fdlibm, therefore their accuracy (and

anything computed using them) is likely implementation dependent.

It suggests using the algorithms in fdlibm, not necessarily fdlibm

(which I take to be a document of some form) itself.

Most, at least, of the standard JavaScript maths functions map directly

to CPU or FPU instructions on the PC; and I'd hope that they do so on

any recent general purpose processor chip. All of those instructions

should give an exact result if possible, and _IIRC_ should be good to

about one LSB otherwise. Therefore the accuracy IMHO should not vary

much with implementation, although the results need not match exactly.

Of course, results are liable to be worse on ill-conditioned problems.

For example, one should generally not solve a quadratic by evaluating

the well-known formula containing +/- twice, instead using whichever

sign gives the bigger result and obtaining the other by a readily-found

simple expression. It's a pity that there have been IIRC no questions

which would justify discussing such, briefly, in the FAQ.

--

(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 7.

Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.

I find MiniTrue useful for viewing/searching/altering files, at a DOS prompt;

free, DOS/Win/UNIX, <URL:http://www.idiotsdelight.net/minitrue/unsupported.