"nan" v. try-catch for arithmetic

Jerry Jensen jhj at jhj.com
Tue Jun 24 18:06:35 EDT 2014


On Jun 24, 2014, at 11:02 AM, Graham Samuel <livfoss at mac.com> wrote:

>  If I put
> 
> sqrt(-1)
> 
> that fires too. But if I put
> 
> (-8)^(2/3)
> 
> I get a result, "nan", and the catch doesn't fire. Why not?

Gee, you'd expect sqrt(-1) and (-1)^(1/2) to evaluate the same. Apparently, the sqrt function checks the parameter to be non-negative, like it says in the dictionary. That would be a lot harder to do in a generalized arithmetic expression. 
.Jerry





More information about the use-livecode mailing list