March 5, 2010 at 8:52 am
Yes CAST is not needed for 10000.0..
probably case statement to differentiage positive and negative values from column1.
March 5, 2010 at 8:55 am
As an alternative to a CASE expression, you can use the SIGN function:
select column1, SIGN(column1) * POWER (abs(column1), 1.8) * CAST(10000 as float) from #t
March 5, 2010 at 9:14 am
Yes, this works... Thanks a lot everyone...
One more point,
I also would like to do the opposite for power function as well...
Instead of ---- POWER (abs(column1), 1.8)
Now I want --- POWER (1.8, column1)
and column1 has values ranging from -970.81 to 970.81...
March 5, 2010 at 9:24 am
Well, mathematically speaking you can have any positive/negative number as an exponent but I'm really intrigued as to what the business logic is for needing this.
Care to elaborate?? 🙂
March 5, 2010 at 9:29 am
To be honest, all I know is this is the function to be applied on the data... don't know the real business logic behind it...
March 5, 2010 at 9:47 am
You need to cast 1.8 as a float. See the following:
create table #temp (
column1 float
);
declare @TestVar float;
set @TestVar = 975.81;
insert into #temp select @TestVar;
select column1
, POWER (column1, 1.8) * 10000.0
, POWER (cast(1.8 as float), column1) * 10000.0
from
#temp;
March 5, 2010 at 9:57 am
works... you guys rock...
Thanks a lot....
March 5, 2010 at 10:08 am
apat (3/5/2010)
Yes, this works... Thanks a lot everyone...One more point,
I also would like to do the opposite for power function as well...
Instead of ---- POWER (abs(column1), 1.8)
Now I want --- POWER (1.8, column1)
and column1 has values ranging from -970.81 to 970.81...
I strongly recommend that you reread the whole thread in order to reevaluate your repeated request.
It's been stated more than once that the calculation you're trying to make cannot be done with SQL Server due to the sheer amount of digits.
To repeat a similar sample given earlier by Lynn:
SELECT POWER(1.8,140) =
547205828359370920000000000000000000.0
If I'm guessing correctly you're looking for a number with som 250 digits...
But there are some good news as well:
I'm able to calculate POWER (1.8, -970.81 ) !
The result is 0.000000000000000000000000000000 (there will be a number different than zero after approx. 250 digits). Accurate enough to round it to Zero?
Viewing 8 posts - 16 through 22 (of 22 total)
You must be logged in to reply to this topic. Login to reply