Difference between revisions of "Logical Operators"

 
(8 intermediate revisions by 5 users not shown)
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. 
+
[[Category:Doc Status C]] <!-- For Lumina use, do not change -->
  
When applied to values other than 0 or 1, other parameter values are interpreted as follows:
+
 
 +
__TOC__
 +
 
 +
 
 +
The logical operators, '''And''', '''Or''', and '''Not''', are used to combine Boolean values.  Analytica uses the values <code>True = 1</code> and <code>False = 0</code>. 
 +
 
 +
When applied to values other than <code>0</code> or <code>1</code>, other parameter values are interpreted as follows:
 
* 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 <code>0</code> or <code>1</code>)
* '''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.
  
= And =
+
==A And B==
  
  A And B
+
True if both «A» and «B» are true. False if either «A» or «B» is false.
  
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]]).
  
In this table, x signifies a numeric value that is not equal to zero (and is not NaN).
+
:{| class="wikitable"
{| border="1"
+
! And !! &nbsp;&nbsp;0&nbsp;&nbsp; !! x !! NaN !! Null  
! And !! &nbsp;&nbsp;0&nbsp;&nbsp; !! x !! NaN !! Null !! Undefined
 
 
|-
 
|-
! 0 || 0 || 0 || 0 || 0 || 0
+
! 0  
 +
| 0  
 +
| 0 || 0 || Null
 
|-
 
|-
! x || 0 || 1 || NaN || 1 || Undefined
+
! x  
 +
| 0 || 1 || NaN || Null
 
|-
 
|-
! NaN || 0 || NaN || NaN || NaN || Undefined
+
! NaN  
 +
| 0 || NaN || NaN || Null
 
|-
 
|-
! Null || 0 || 1 || NaN || Null || Undefined
+
! Null
|-
+
| Null || Null || Null || Null  
! Undefined || 0 || Undefined || Undefined || Undefined  || Undefined
 
 
|}
 
|}
  
= Or =
+
==A Or B==
  
  A or B
+
True if «A» or «B», or both, are true.  
  
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]]).
  
In this table, x signifies a numeric value that is not equal to zero (and is not NaN).
+
:{| class="wikitable"
{| border="1"
+
! Or !! &nbsp;&nbsp;0&nbsp;&nbsp; !! &nbsp;&nbsp;x&nbsp;&nbsp; !! NaN !! Null  
! And !! &nbsp;&nbsp;0&nbsp;&nbsp; !! &nbsp;&nbsp;x&nbsp;&nbsp; !! NaN !! Null !! Undefined
 
 
|-
 
|-
! 0 || 0 || 1 || NaN || 0 || Undefined
+
! 0  
 +
| 0 || 1 || NaN || Null
 
|-
 
|-
! x || 1 || 1 || 1 || 1 || 1
+
! x  
 +
| 1 || 1 || 1 || Null
 
|-
 
|-
! NaN || NaN || 1 || NaN || NaN || Undefined
+
! NaN  
 +
| NaN || 1 || NaN || Null
 
|-
 
|-
! Null || 0 || 1 || NaN || Null || Undefined
+
! Null  
|-
+
| Null || Null || Null || Null  
! Undefined || Undefined || 1 || Undefined || Undefined  || Undefined
 
 
|}
 
|}
  
= Not =
+
== Not A==
 +
True if «A»  is false.
  
{| border="1"
+
:{| class="wikitable"
! Not !! &nbsp;&nbsp;0&nbsp;&nbsp; !! &nbsp;&nbsp;x&nbsp;&nbsp; !! NaN !! Null !! Undefined
+
! Not !! &nbsp;&nbsp;0&nbsp;&nbsp; !! &nbsp;&nbsp;x&nbsp;&nbsp; !! NaN !! Null  
 
|-
 
|-
! || 1 || 0 || NaN || Null || Undefined
+
| || 1 || 0 || NaN || Null  
 
|}
 
|}
 +
 +
==See Also==
 +
* [[INF, NAN, Null, and Undefined]]
 +
* [[Comparison Operators]]
 +
* [[Expression_Syntax#Operator_Precedence|Operator precedence]]
 +
* [[Operators]]
 +
* [[Boolean or truth values]]

Latest revision as of 20:51, 20 April 2016



The logical operators, And, Or, and Not, are used to combine Boolean values. 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.

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 Null
x 0 1 NaN Null
NaN 0 NaN NaN Null
Null Null Null Null Null

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).

Or   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 A

True if «A» is false.

Not   0     x   NaN Null
1 0 NaN Null

See Also

Comments


You are not allowed to post comments.