robert.rozee Guru Joined: 31/12/2012 Location: New ZealandPosts: 2552
Posted: 01:44pm 16 Jan 2025
this also works:
Print double(--a%)
but unfortunately this does not:
Print double(+a%)
my vote would be for +a% for the reasons that:
+ using it adds just a single token to the program's length rather than two tokens,
+ applying the same rule to + as is applied to - would reduce the size of and simplify the interpreter,
+ it is mathematically correct.
one could even argue that the error produced:
> > Print double(+a%) Error: Expression syntax >
represents a... bug. if - is accepted as a valid unary operator that changes sign, then surely +must be accorded the same status, as a unary operator that does not change sign.
as a bug fix, this could even be a good excuse for releasing a new revision of mx170 mmbasic
cheers, rob :-)
addendum: look what works on the mx170:
> > ?+-+2 -2 > ? ---2 -2 > ? +--2 2 > ?--+2 2 >
addendum 2: looks like the code that evaluates expressions for print accepts '+' as a unary operator, but the function parser does not. Edited 2025-01-16 23:58 by robert.rozee