Bug in Let/MIN statement?

lforbes

New Member
Have found that the following does not maintain the specified minimum value:

x = x - 2 MIN 1

Successive executions of the instruction result in x = 5, 3, 1, 255, 253 etc.

I suppose what is going on is that 255 is greater than 1 (there being no negative integers) so the condition is considered met, even if it is not. Maybe it's not a bug, just a quirk (?).
 

andrewpro

New Member
It's called underflow, and that's par for the course, really. Basically what's happening is that it's not stopping at 0 (as most micro's dont do!) If you make the line just prior to it a +1, made it a min 2 then on the next line subtract 1, it should work out the way you want it to.

X+1
x=x-2 min 1
x-1

That should keep it above 0, and keep it from rolling to 255. Just be careful you dont add 1 to 255, or youll end up at 0!!

--Andy P
 
Top