Reputation: 123
select power(1.005,4) [Power]
gives 1.020
select 1.005*1.005*1.005*1.005 [Manual]
gives 1.020150500625
i need the latter result but don't want to do manually. 4th Power in this case but will be variable.
please advise. thanks
Upvotes: 0
Views: 168
Reputation: 1269973
Based on your syntax, I assume you are using SQL Server. As explained in the documentation for power()
:
Returns the same type as submitted in float_expression. For example, if a decimal(2,0) is submitted as float_expression, the result returned is decimal(2,0).
SQL Server interpets numeric inputs as decimals, not floats. So, if you want the full value, convert the value before calling the function:
select power(convert(float, 1.005), 4) as [Power]
Here is a Rextester comparing the different approaches.
Upvotes: 1