Difference between revisions of "Logical Operators"

(Updated truth tables, eliminating Undefined and changing to semantics agreed on with Max.)
Line 1: Line 1:
 
[[category:Operators]]
 
[[category:Operators]]
 +
 
Logical operators are used to combine boolean assertions.  Analytica uses the values True=1 and False=0.   
 
Logical operators are used to combine boolean assertions.  Analytica uses the values True=1 and False=0.   
  
Line 5: Line 6:
 
* a '''non-zero numeric''' is treated as true
 
* a '''non-zero numeric''' is treated as true
 
* '''NaN''' is treated as ambiguous (could be 0 or 1)
 
* '''NaN''' is treated as ambiguous (could be 0 or 1)
* '''Null''' is treated as a No-op
+
* '''Null''' results in a warning, with a Null result.
* '''Undefined''' results in an undefined result (if the result is not fully determined by the other parameter)
 
 
* Any '''other''' data type results in an error.
 
* Any '''other''' data type results in an error.
 +
 +
Note: The value special Undefined is considered deprecated in Analytica 4.0.  Null is now used exclusively for a non-existent value from within Analytica expressions.
  
 
[[INF, NAN, Null, and Undefined]]
 
[[INF, NAN, Null, and Undefined]]
Line 18: Line 20:
 
In this table, x signifies a numeric value that is not equal to zero (and is not NaN).
 
In this table, x signifies a numeric value that is not equal to zero (and is not NaN).
 
{| border="1"
 
{| border="1"
! And !!   0   !! x !! NaN !! Null !! Undefined
+
! And !!   0   !! x !! NaN !! Null  
|-
 
! 0 || 0 || 0 || 0 || 0 || 0
 
 
|-
 
|-
! x || 0 || 1 || NaN || 1 || Undefined
+
! 0 || 0 || 0 || 0 || 0
 
|-
 
|-
! NaN || 0 || NaN || NaN || NaN || Undefined
+
! x || 0 || 1 || NaN || Null
 
|-
 
|-
! Null || 0 || 1 || NaN || Null || Undefined
+
! NaN || 0 || NaN || NaN || Null
 
|-
 
|-
! Undefined || 0 || Undefined || Undefined || Undefined  || Undefined
+
! Null || Null || Null || Null || Null
 
|}
 
|}
  
Line 39: Line 39:
 
In this table, x signifies a numeric value that is not equal to zero (and is not NaN).
 
In this table, x signifies a numeric value that is not equal to zero (and is not NaN).
 
{| border="1"
 
{| border="1"
! And !!   0   !!   x   !! NaN !! Null !! Undefined
+
! And !!   0   !!   x   !! NaN !! Null  
|-
 
! 0 || 0 || 1 || NaN || 0 || Undefined
 
 
|-
 
|-
! x || 1 || 1 || 1 || 1 || 1
+
! 0 || 0 || 1 || NaN || Null
 
|-
 
|-
! NaN || NaN || 1 || NaN || NaN || Undefined
+
! x || 1 || 1 || 1 || Null
 
|-
 
|-
! Null || 0 || 1 || NaN || Null || Undefined
+
! NaN || NaN || 1 || NaN || Null
 
|-
 
|-
! Undefined || Undefined || 1 || Undefined || Undefined  || Undefined
+
! Null || Null || Null || Null || Null
 
|}
 
|}
  
Line 55: Line 53:
  
 
{| border="1"
 
{| border="1"
! Not !!   0   !!   x   !! NaN !! Null !! Undefined
+
! Not !!   0   !!   x   !! NaN !! Null  
 
|-
 
|-
! || 1 || 0 || NaN || Null || Undefined
+
! || 1 || 0 || NaN || Null  
 
|}
 
|}

Revision as of 07:40, 20 February 2007


Logical operators are used to combine boolean assertions. Analytica uses the values True=1 and False=0.

When applied to values other than 0 or 1, other parameter values are interpreted as follows:

  • a non-zero numeric is treated as true
  • NaN is treated as ambiguous (could be 0 or 1)
  • Null results in a warning, with a Null result.
  • Any other data type results in an error.

Note: The value special Undefined is considered deprecated in Analytica 4.0. Null is now used exclusively for a non-existent value from within Analytica expressions.

INF, NAN, Null, and Undefined

And

A And B

True if both A and B are true. False if either A or B is false.

In this table, x signifies a numeric value that is not equal to zero (and is not NaN).

And   0   x NaN Null
0 0 0 0 0
x 0 1 NaN Null
NaN 0 NaN NaN Null
Null Null Null Null Null

Or

A or B

True if A or B or both are true.

In this table, x signifies a numeric value that is not equal to zero (and is not NaN).

And   0     x   NaN Null
0 0 1 NaN Null
x 1 1 1 Null
NaN NaN 1 NaN Null
Null Null Null Null Null

Not

Not   0     x   NaN Null
1 0 NaN Null
Comments


You are not allowed to post comments.