Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Conditional operator?
#5
(09-16-2014, 08:57 PM)einar Wrote:
Code:
IF (a < 30) THEN
    LET a = a + 2
ELSE
    LET a = a + 1
END IF

In Sinclair BASIC you can use AND and OR expressions for that.

In this case you'd need this:
LET a = ((a+2) AND (a < 30)) + ((a+1) AND (a >= 30))

Another example to truncate a float number:
LET n = -23.4
LET t = INT n + (1 AND SGN n = -1)

Unfortunately this doesn't work with Zx Basic Sad
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)