Solved

POWER function

Posted on 2001-07-26
8
359 Views
Last Modified: 2007-12-19
I am trying to execute the following and I'm receiving an error:

SELECT POWER(-192427.50013516, -.33333 )

The error is "A domain error occurred"

Anybody know a way around this? I know that usually when you get this error, it means that the arguments are outside the valid range, but, I can't find what the valid range might be.
0
Comment
Question by:songstre
  • 4
  • 4
8 Comments
 
LVL 30

Expert Comment

by:SteveGTR
ID: 6321784
Domain errors occur when the value provided in the mathematical function is not a valid value.

SET ARITHIGNORE ON, which causes no warning message to be displayed. Both the SET ARITHABORT and SET ANSI_WARNINGS settings override the SET ARITHIGNORE setting.
0
 
LVL 1

Author Comment

by:songstre
ID: 6321822
OK, but I still don't get a value. If the values provided are outside the valid values of the function, then what are the valid values of the function? Then I can check them and provide defaults.
0
 
LVL 1

Author Comment

by:songstre
ID: 6321839
OK, but I still don't get a value. If the values provided are outside the valid values of the function, then what are the valid values of the function? Then I can check them and provide defaults.
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 30

Expert Comment

by:SteveGTR
ID: 6321961
I think that you run into problems when you try to raise a negative number to a negative number less then zero:

power(-1, -.1)

You could check to make sure that the second number is not less than zero when the first number is negative. Or you could just treat these errors as zero's. I'm not sure if your application permits this or not.

SET ARITHIGNORE ON

select isnull(power(-.1, .1), 0)
0
 
LVL 1

Author Comment

by:songstre
ID: 6322029
I tried using isnull. It's not returning null. There's just nothing. Also, power(-1, .1) doesn't work either and the second arg is not negative.
0
 
LVL 30

Expert Comment

by:SteveGTR
ID: 6322506
Sorry for the typo... So this doesn't print zero?

SET ARITHIGNORE ON

select isnull(power(-.1, -.1), 0)

Is that what you are saying? I'm running SQL 7 here --- what are you using?

0
 
LVL 1

Author Comment

by:songstre
ID: 6322610
SQL 2000

select isnull(power(-.1, -.1), 0)

gives me nothing, not 0.

And I found out that it is not mathematically possible. If you do the above calculation in Calculator, you get 'Invalid Input for function.'

I'll give you the points for trying, though.
0
 
LVL 30

Accepted Solution

by:
SteveGTR earned 50 total points
ID: 6322829
>>And I found out that it is not mathematically possible.
>>If you do the above calculation in Calculator, uyou >>get 'Invalid Input for function.'

I believe my first message stated this fact...

"Domain errors occur when the value provided in the mathematical function is not a valid value."

That's odd that SQL doesn't print anything. Well thanks :)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question