Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Committers > Re: pgsql: Have...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 11 Topic 16074 of 17642
Post > Topic >>

Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather than an error, and have 0 ^

by tgl@[EMAIL PROTECTED] (Tom Lane) May 9, 2008 at 10:37 AM

Simon Riggs <simon@[EMAIL PROTECTED]
> writes:
> Wikipedia says that exponentiation of zero to a negative power implies
> division by zero, so shouldn't we throw a "division by zero" error?

I think it should be a specific message like "zero raised to a negative
power is undefined".  It's not like it's going to take us any extra code
to know that we are faced with that case.

BTW, I realized that SQL:2003 spells it all out for us in explicit
detail:

12)If <power function> is specified, then let NVEB be the <numeric value
expression base>, then let VB be the value of NVEB, let NVEE be the
<numeric value expression exponent>, and let VE be the value of NVEE.

Case: 

a) If either VB or VE is the null value, then the result is the null
value. 

b) If VB is 0 (zero) and VE is negative, then an exception condition is
raised: data exception Ñ invalid argument for power function.

c) If VB is 0 (zero) and VE is 0 (zero), then the result is 1 (one). 

d) If VB is 0 (zero) and VE is positive, then the result is 0 (zero). 

e) If VB is negative and VE is not equal to an exact numeric value with
scale 0 (zero), then an exception condition is raised: data exception
Ñ invalid argument for power function.

f) If VB is negative and VE is equal to an exact numeric value with
scale 0 (zero) that is an even number, then the result is the result of
	EXP(NVEE*LN(-NVEB)) 

g) If VB is negative and VE is equal to an exact numeric value with
scale 0 (zero) that is an odd number, then the result is the result of
	-EXP(NVEE*LN(-NVEB)) 

h) Otherwise, the result is the result of 
	EXP(NVEE*LN(NVEB)) 


			regards, tom lane

-- 
Sent via pgsql-committers mailing list (pgsql-committers@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
 




 11 Posts in Topic:
pgsql: Have numeric 0 ^ 4.3 return 1, rather than an error, and
momjian@[EMAIL PROTECTED]  2008-05-08 19:25:38 
Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather than
neilc@[EMAIL PROTECTED]   2008-05-08 14:00:35 
Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather
bruce@[EMAIL PROTECTED]   2008-05-08 18:18:00 
Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather than an error,
tgl@[EMAIL PROTECTED] (T  2008-05-08 18:23:31 
Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather
bruce@[EMAIL PROTECTED]   2008-05-08 18:34:20 
Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather than
simon@[EMAIL PROTECTED]   2008-05-09 09:00:36 
Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather than an error,
tgl@[EMAIL PROTECTED] (T  2008-05-09 10:37:07 
Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather
bruce@[EMAIL PROTECTED]   2008-05-09 11:36:07 
Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather than an error,
tgl@[EMAIL PROTECTED] (T  2008-05-09 11:57:42 
Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather
bruce@[EMAIL PROTECTED]   2008-05-09 11:58:41 
Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather
bruce@[EMAIL PROTECTED]   2008-05-09 17:32:26 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Oct 11 6:25:57 CDT 2008.