Comments on negative and parentheses

mynet43

Member
The description under the 'let' command says that negative numbers and parentheses are not supported and that the parsing works strictly from left to right.

Comment 1: The negative arithmetic actually works if you write the equation like:

temp = 0-12 + 15

The answer comes out 3, which is right. Since this works already, how about including the negate feature when the first item is preceded by a minus sign?

Comment 2: Even though you don't support parentheses when parsing, it would be really helpful if you included precedence, wherein the * and / are performed before the + or -.
It took me a while to figure out that

temp = 12 - 3*i

is parsed as (12 - 3)*i rather than as 12 - (3*i) which is what you get if you run it on VB.

Just food for thought. Keep up the good work.

Jim


 
 

Technical

Technical Support
Staff member
temp = -12 + 15 is already supported by the compiler and will work as you expect.

But it is not true support of negative numbers, in fact it is a really a double overflow - back to 246 and then forward again to 3.

Strictly left to right means just that, no priority is given to anything.
 

mynet43

Member
Am I missing something?

I ran the following program with the simulator:

symbol temp = b0
loop1:
temp = -12 + 15
if temp <> 3 then loop1
end

When it executes the line:
temp = -12 + 15
it displays the error message:
"Unknown math operator in let."

When I substitute:
temp = 0-12 + 15 then everything works great!

Did you try it before you said it would work?:)


 
 

BeanieBots

Moderator
b0=-12+15 compiles and runs OK for me.
Editor 5.0.8 enhanced mode enabled.
What editor version do you have?
Do you have "enhanced" selected?
 

hippy

Ex-Staff (retired)
It compiles, runs on a PICAXE and simply seems to be a buggette in the Simulator.
 

mynet43

Member
Forgot to say. Yes, I'm running 5.0.8, with the enhanced compiler.

You can't use the simulator unless the enhanced compiler is turned on.

 
 

mynet43

Member
Technical:

Would you please fix the minor bug in the simulator that doesn't handle negative correctly.

b0 = -12 + 15

works fine with the compiler but gives an error in the simulator.

Thanks


 
 

Technical

Technical Support
Staff member
It is fixed
Make sure your 5.08 patch files have updated correctly.

http://www.rev-ed.co.uk/picaxe/forum/topic.asp?topic_id=6419&forum_id=6
 

mynet43

Member
Not sure what you mean about the 5.0.8 patch.

When I display Help/About, it shows:

PICAXE Programming Editor
Version 5.0.8 (Syntax DLL 131072)

Should I have something else?

If I run the following code in the 08M, it displays '3' on the terminal.

b0 = -12 + 15
sertxd(#b0)

When I run the same code in the simulator, I get the message: "Unknown math operator in let" when it executes the first line.

Please let me know if I'm missing something.

Thanks for your help.

 
 

Technical

Technical Support
Staff member
The Help>About mesage is the progedit file, nothing to do with the compilers. Please follow the process already described to manually delete the compilers and then reinstall the patch!
 

mynet43

Member
Thanks for your help. That solved it.

It would be nice if the help/about menu would also provide information about the compiler.

Thanks again,

Jim


 
 
Top