With Xcode 11.1 if I run a playground with:
pow(10 as Double, -2) // 0.01
I get same output using Float:
pow(10 as Float, -2) // 0.01
But if I try to use the pow(Decimal, Int) as in:
pow(10 as Decimal, -2) // NaN
Does anybody know why?
Is there a better way to deal with positive and negative exponent with pow and Decimal? I need Decimal as they behave as I expect with currency value.
EDIT: I know how to resolve that from math perspective, I'd like to understand why it happens and/or if it can be solved without adding on the cyclomatic complexity of my code (e.g. checking if the exponent is negative and executing 1 / pow)