On 13 November 2015 at 23:10, Tom Lane <t...@sss.pgh.pa.us> wrote: > One more thing: the approach you used in power_var() of doing a whole > separate exp * ln(base) calculation to approximate the result weight > seems mighty expensive, even if it is done at minimal precision. > Couldn't we get a good-enough approximation using basically > numericvar_to_double_no_overflow(exp) * estimate_ln_weight(base) ? >
I can't see a way to make that work reliably. It would need to be 10^estimate_ln_weight(base) and the problem is that both exp and ln_weight could be too big to fit in double variables, and become HUGE_VAL, losing all precision. An interesting example is the limit of (1+1/x)^x as x approaches infinity which is e (the base of natural logarithms), so in that case both the exponent and ln_weight could be arbitrarily big (well too big for doubles anyway). For example (1+1/1.2e+500)^(1.2e500) = 2.7182818284... Regards, Dean -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers