"nan" v. try-catch for arithmetic

Mark Wieder mwieder at ahsoftware.net
Tue Jun 24 18:56:22 EDT 2014


Graham-

Tuesday, June 24, 2014, 11:02:56 AM, you wrote:

> I get a result, "nan", and the catch doesn't fire. Why not? Maybe
> someone can explain what the engine is doing here - or is it just an
> obscure bug?

It fires for me in either case.
To get the actual error code, change the code to

try
  put value(fld "myField") into testResult
catch e
  answer e
  exit mouseUp
end try

That way you see that sqrt(-1) results in 555 "sqrt: domain error" and
(-8)^(2/3) results in 402 "pow: range error (overflow)". Both of them
also return "-nan", as expected.

-- 
-Mark Wieder
 ahsoftware at gmail.com

This communication may be unlawfully collected and stored by the National 
Security Agency (NSA) in secret. The parties to this email do not 
consent to the retrieving or storing of this communication and any 
related metadata, as well as printing, copying, re-transmitting, 
disseminating, or otherwise using it. If you believe you have received 
this communication in error, please delete it immediately.





More information about the use-livecode mailing list