|
Post by tsh73 on Apr 13, 2018 8:29:58 GMT -5
Who might knew? VAL processes several signs. So valid are: print val("++1") print val("+-1") print val("--1") and even print val("+-+--+++--1") (!)
And we could misuse that (count parity of '-' ).
for k = 1 to 10 s$="":m=0 for i = 1 to 10 if rnd(0)<.5 then s$=s$+"+" else s$=s$+"-": m=m+1 next print "is ";s$;" has odd number of '-'?", if val(s$;"1")<0 then print "Odd ";m else print "Even ";m next
|
|
|
Post by Carl Gundel on Apr 13, 2018 9:07:53 GMT -5
Who might knew? VAL processes several signs. So valid are: print val("++1") print val("+-1") print val("--1") and even print val("+-+--+++--1") (!) And we could misuse that (count parity of '-' ). for k = 1 to 10 s$="":m=0 for i = 1 to 10 if rnd(0)<.5 then s$=s$+"+" else s$=s$+"-": m=m+1 next print "is ";s$;" has odd number of '-'?", if val(s$;"1")<0 then print "Odd ";m else print "Even ";m next
Have fun with that.
|
|
|
Post by tsh73 on Apr 13, 2018 15:00:47 GMT -5
It goes even weirder then that:
print val("1.2e---3") print val("1.2e-+-3") results in
0.0012 1200.0
|
|