Zainul Abideen K T
Zainul Abideen K T

Reputation: 71

Why is the pow function returning NAN?

When using the following function, I sometimes get NAN returned for some inputs; I think I'm getting NAN when I'm using negative values for the variables. How can I fix this?

pow(($LY/$FY),(1/10)) - 1

Upvotes: 0

Views: 899

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324680

Add a check beforehand to ensure that $LY/$FY is positive. Alternatively, depending on what you're using it for, use the abs() function on that fraction to change negative numbers to positive ones.

Upvotes: 2

Related Questions