Possibly -s_w3=1023-s_w3 max 995 min 0
What should this look like?
marks, As I demonstrated above, "min 0" is meaningless, since a PICAXE integer can never be less than 0.Hi rq3,
I haven't used max or min but looks like your also trying to invert to 995 to 0.
perhaps try
Rich (BB code):w3=w3 max 995 min 0 : W3 =995-w3
w3 = w3 max 995 ; 0 to 995>65535 = 0 to 955
w3 = w3 min 14 max 1009-14 ; 0<14 to 1009>65535 = 0 to 995
w3 = 1023 Min w3 - w3 Max 995 ; 0<28 to 1023>65535 = 995 to 0
w3 = 995 Min w3 - w3 ; 0 to 995>65535 = 995 to 0
Thanks everyone! This simulates properly:The main lesson to take away is that "X - N Min 0" doesn't work, doesn't prevent underflow wrapround.
That has to be "X Min N - N"
#picaxe20m2
main:
for w0=0 to 1023 step 5
w1=995 Min w0-w0
sertxd (#w0," ",#w1,cr,lf)
next w0
MIN means ensure greater than a minimum. 4 is bigger than the minimum 0 so it remains as 4. When you subtract 'b0', if that's greater than 4 the result would go negative, but negatives are large positive numbers, eg 5-4 = -1, -1 is $FFFF (65535). When that is truncated to an 8-bit byte it becomes $FF (255).how come the value is not limited to a minimum of 0