"nan" v. try-catch for arithmetic
m.schonewille at economy-x-talk.com
Tue Jun 24 23:41:12 CEST 2014
If I execute (-8)^(2/3) in LiveCode 6.6.1, I get "execution error at
line 7 (pow: range error (overflow)), char 17", i.e. an execution error
instead of NaN.
Economy-x-Talk Consulting and Software Engineering
Installer Maker for LiveCode:
Buy my new book "Programming LiveCode for the Real Beginner"
LiveCode on Facebook:
On 6/24/2014 20:02, Graham Samuel wrote:
> I have a bit of code that looks for input errors where the user is supposed to write an arithmetic expression into a field. The relevant fragment looks like this
> put value(fld "myField") into testResult
> answer "oops, that's not a valid real number. Try again"
> exit mouseUp
> end try
> Now I input a legitimate expression like 3+sin(pi/2)
> the catch doesn't fire, as expected. If I put in something which isn't a well-formed expression, like
> ardvaark + 92
> it does fire, as expected. If I put
> that fires too. But if I put
> 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?
More information about the use-livecode