LOG10E mystery constant
Waldemar Horwat
waldemar at google.com
Thu Mar 3 18:04:56 PST 2011
On 02/20/11 21:16, Mark S. Miller wrote:
> The specification of Math.LOG10E says:
>
> 15.8.1.5 LOG10E
>
> The Number value for the base-10 logarithm of e, the base of the natural logarithms; this value is approximately 0.4342944819032518.
>
> This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
>
> NOTE The value of Math.LOG10E is approximately the reciprocal of the value of Math.LN10.
>
>
> This is the only constant whose actual value differs across browsers:
>
> 0.43429448190325176 v8 version 2.3.9 [console: dumb]
> 0.4342944819032518 Chrome 11.0.672.2 dev
> 0.4342944819032518 Chrome 11.0.672.0 canary build
> 0.4342944819032518 FF 3.6.13
> 0.4342944819032518 FF 4.0b12pre
> 0.43429448190325176 Safari 5.0.1 (5533.17.8)
> 0.43429448190325176 WebKit nightly Safari 5.0.1 (5533.17.8, r78794)
> 0.4342944819032518 Opera 11.01 Build 1190
> 0.4342944819032518 IE 9.0.8080.16413CO
>
> Anyone know why? Which value is more correct?
>
> I don't really care about Math.LOG10E, but it's easier to write tests if only one value is actually correct.
0.4342944819032518 is correct.
0.43429448190325176 is wrong.
The high-precision value of log10(e) is 0.4342944819032518276511289189166050822943970058036665661144...
The closest IEEE double to this is 0.43429448190325181666793241674895398318767547607421875, which prints as 0.4342944819032518.
0.43429448190325176 evaluates to the different IEEE double 0.434294481903251761156781185491126962006092071533203125.
On 02/20/11 21:26, John Cowan wrote:
> The two values are really the same value when represented as an IEEE
> double. The difference is in the printing routine, not the internal
> representation. Specifically, the "...2518" browsers are rounding, the
> "...25176" browsers are not.
No, that's not what is happening here.
Waldemar
More information about the es-discuss
mailing list