The problem I have with POWER/LOG is that although they seem to adapt to the data-type you send in (the output variable type matches the first variable's type), the precision seems to stop close to the limits of a float, resulting in incorrect output. Example:
DECLARE @ten numeric(18,4) = 10
declare @num numeric(18,4) = 234567890
SELECT power(@ten,log(@num,@ten))
Ouput = 234567890.0000 Which is correct
However, if we increase the precision, as follows:
DECLARE @ten numeric(18,6) = 10
declare @num numeric(18,6) = 234567890
SELECT power(@ten,log(@num,@ten))
Output = 234567889.999999 Which is not correct, but rounding could fix it (?)
Lastly, if you change the precision to something like Numeric(18,9), the problem gets worse:
DECLARE @ten numeric(18,9) = 10
declare @num numeric(18,9) = 234567890
SELECT power(@ten,log(@num,@ten))
Output = 234567889.999999310 Which is not correct, and rounding would not fix it.
I'm assuming the issue is that although the POWER and Log function may accept very precise data types, their working variables must be float types? Does anyone have any experience with this, or experience working around it?