vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Richard Wang wrote: > I expected 0 ^ 123.3 to be 0, but it reported error as follows > > postgres=# select 0 ^ 123.3; > ERROR: cannot take logarithm of zero > > I find that there is a bug in numeric_power() function > the function caculates a ^ b based on the algorithm e ^ (lna * b) > as you see, ln0 is not valid I have developed the attached patch which fixes 0 ^ 123.3. It also fixes the case for 0 ^ 0.0 so it returns 1 instead of an error --- see the C comment for why one is the proper return value. float pow() already returned one in this case: test=> select 0 ^ 0; ?column? ---------- 1 (1 row) test=> select 0 ^ 0.0; ?column? ---------- 1 (1 row) test=> select 0 ^ 3.4; ?column? ---------- 1 (1 row) -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. + -- Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-patches |
| |||
| Bruce Momjian <bruce@momjian.us> writes: > I have developed the attached patch which fixes 0 ^ 123.3. Did you actually read the wikipedia entry you cited? regards, tom lane -- Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-patches |
| |||
| Tom Lane wrote: > Bruce Momjian <bruce@momjian.us> writes: > > I have developed the attached patch which fixes 0 ^ 123.3. > > Did you actually read the wikipedia entry you cited? Considering that 0::float8 ^ 0::float8 yields 1, making the numeric operator do the same might not be completely unreasonable, but I find the rationale that it is better for discrete mathematics fairly ludicrous on multiple levels. -- Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-patches |
| |||
| Tom Lane wrote: > Bruce Momjian <bruce@momjian.us> writes: > > I have developed the attached patch which fixes 0 ^ 123.3. > > Did you actually read the wikipedia entry you cited? Yes: The evaluation of 0^0 presents a problem, because different mathematical reasoning leads to different results. The best choice for its value depends on the context. According to Benson (1999), "The choice whether to define 00 is based on convenience, not on correctness."[2] There are two principal treatments in practice, one from discrete mathematics and the other from analysis. .... The computer programming languages that evaluate 00 to be 1[8] include J, Java, Python, Ruby, Haskell, ML, Scheme, MATLAB, bc, R programming language, and Microsoft Windows' Calculator. -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. + -- Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-patches |
| |||
| Bruce Momjian wrote: > Tom Lane wrote: > > Bruce Momjian <bruce@momjian.us> writes: > > > I have developed the attached patch which fixes 0 ^ 123.3. > > > > Did you actually read the wikipedia entry you cited? But that's about 0^0, not about 0^123.3. See this other subsection: http://en.wikipedia.org/wiki/Exponen...Powers_of_zero 0^123.3 is 0, not 1. -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support -- Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-patches |
| |||
| Alvaro Herrera wrote: > Bruce Momjian wrote: > > Tom Lane wrote: > > > Bruce Momjian <bruce@momjian.us> writes: > > > > I have developed the attached patch which fixes 0 ^ 123.3. > > > > > > Did you actually read the wikipedia entry you cited? > > But that's about 0^0, not about 0^123.3. See this other subsection: > > http://en.wikipedia.org/wiki/Exponen...Powers_of_zero > > 0^123.3 is 0, not 1. Ah, got it, and I updated the patch to remove the commment about "discrete". -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. + -- Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-patches |
| |||
| Bruce Momjian wrote: > Ah, got it, and I updated the patch to remove the commment about > "discrete". The page also says that 0^x is undefined when x is negative, not sure about that one but I don't see it in your patch. -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support -- Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-patches |
| |||
| Alvaro Herrera wrote: > Bruce Momjian wrote: > > > Ah, got it, and I updated the patch to remove the commment about > > "discrete". > > The page also says that 0^x is undefined when x is negative, not sure > about that one but I don't see it in your patch. That one was already handled: test=> select 0 ^ -1; ERROR: invalid argument for power function test=> select 0 ^ -1.0; ERROR: invalid argument for power function -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. + -- Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-patches |
| ||||
| Applied. --------------------------------------------------------------------------- Bruce Momjian wrote: > Alvaro Herrera wrote: > > Bruce Momjian wrote: > > > Tom Lane wrote: > > > > Bruce Momjian <bruce@momjian.us> writes: > > > > > I have developed the attached patch which fixes 0 ^ 123.3. > > > > > > > > Did you actually read the wikipedia entry you cited? > > > > But that's about 0^0, not about 0^123.3. See this other subsection: > > > > http://en.wikipedia.org/wiki/Exponen...Powers_of_zero > > > > 0^123.3 is 0, not 1. > > Ah, got it, and I updated the patch to remove the commment about > "discrete". > > -- > Bruce Momjian <bruce@momjian.us> http://momjian.us > EnterpriseDB http://enterprisedb.com > > + If your life is a hard drive, Christ can be your backup. + > > -- > Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-patches -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. + -- Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-patches |
| Thread Tools | |
| Display Modes | |
| |