I am trying to improve the compliance of our interpreter with EcmaScript
5.1, and have just been working on the implementation of toPrecision.

I'm not sure that the algorithm given is consistent with existing
implementations if the precision is 1.

As far as I can see the spec. would result in a trailing period which
doesn't seem expected and doesn't seem to match existing implementations.

Taking an example of 123.456 and working this through.

At stage 10a e should be 2 and n be 1
At stage 10b m will be set to "1"

At stage 10c e(=2) > p(=1)
At stage 10c(i) a will be "1" and b the empty string
At stage 10c(ii) m is updated to a + '.' + c which would appear to be "1."
10c(iii-iv) will evaluate c and d as "+" and "2" respectively
10c(v) will update m to "1.e+2"

I take it I've missed something here?

--
Neil
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to