This page last updated 98/04/30

Logical operations on cfx-9x50s

The cfx-9x50 calcs handle boolean logic slightly differently to the previous calcs.

For example, the statement

  I = 3 => Goto 5
would be handled as follows:

     Pre-cfx-9x50s               cfx-9x50s
     
     I = 3 => Goto 5             I = 3 => Goto 5
     (I) = (3) => (Goto 5)       (I = 3) => (Goto 5)
     (Goto 5)                    (1) => (Goto 5)
                                 (Goto 5)

The difference is that on older calcs the relative comparison operators (=, <, >, <=, >=, <>) were considered to be syntactic breakpoints, part of the conditional statement format. To test whether or not to carry out the Goto 5 they simply tested whether I = 3.

On cfx-9x50s though, every expression which includes a relative comparison operator is assigned a value of either 0 or 1 when it is evaluated (0 = FALSE, 1 = TRUE). A condition is then carried out as long as the entire expression which precedes the => is non-zero. So on a cfx-9x50, this is legal code:

  123.456 => "WIBBLE"

Uses of boolean expressions

With these extended boolean expressions it becomes possible to use some clever tricks to shorten your code.

For example, this code

  X = 3 => 20 -> Y
  X <> 3 => 50 -> Y
can be converted to

  50 - 30(X=3) -> Y

You can also put a number of boolean expressions together. For example, instead of using

  If ((X > 30) And (Y < 20))
  Then Y + 27 -> Y
  IfEnd

you can use

  Y + 27(X > 30)(Y < 20) -> Y

You can shorten expressions by using the logical similarities between " And " and " Or " and multiplication and addition.

For example, instead of:

  ((X = 1) And (X-3 > B)) Or (Y=2) => Goto 5

you can use

  (X = 1)(X-3 > B) + (Y = 2) => Goto 5

For a number of more advanced examples, see lists.html.


This page was created by Tom Lynn. Comments etc. to: tom-calcs@mythic-beasts.com.

W3C Wilbur Checked!