Class FunctionsBoolean

java.lang.Object
net.objecthunter.exp4j.extras.FunctionsBoolean

public final class FunctionsBoolean extends Object
This class contains a set of commonly used boolean functions and constants.

The boolean value rules are the same the we use in the operators:

  1. if the absolute value is less than Operator.BOOLEAN_THRESHOLD it will be considered false.
  2. if the absolute value is bigger or equal than Operator.BOOLEAN_THRESHOLD it will be considered true
  3. the recommended approach is to use functions or operators that return boolean values, like the comparison operators or the TRUE and FALSE constants
  4. the TRUE constant will always return 1.0 and FALSE will always return 0.0
Since:
0.6-riddler
Author:
Federico Vera <[email protected]>
See Also:
  • Field Details

    • NOT

      public static final Function NOT
      Logical function NOT
           a | ~a
           --+--
           0 | 1
           1 | 0
       
      Since:
      0.6-riddler
      See Also:
      • Operators.NOT
    • AND

      public static final Function AND
      Logical function AND
           a | b | a&b
           --+---+----
           0 | 0 |  0
           0 | 1 |  0
           1 | 0 |  0
           1 | 1 |  1
       
      Since:
      0.6-riddler
      See Also:
      • Operators.AND
    • OR

      public static final Function OR
      Logical function OR
           a | b | a|b
           --+---+----
           0 | 0 |  0
           0 | 1 |  1
           1 | 0 |  1
           1 | 1 |  1
       
      Since:
      0.6-riddler
      See Also:
      • Operators.OR
    • XOR

      public static final Function XOR
      Logical function XOR
           a | b | a^b
           --+---+----
           0 | 0 |  0
           0 | 1 |  1
           1 | 0 |  1
           1 | 1 |  0
       
      Since:
      0.6-riddler
    • NAND

      public static final Function NAND
      Logical function NAND
           a | b | !(a&b)
           --+---+-------
           0 | 0 |   1
           0 | 1 |   1
           1 | 0 |   1
           1 | 1 |   0
       
      Since:
      0.6-riddler
    • NOR

      public static final Function NOR
      Logical function NOR
           a | b | !(a|b)
           --+---+-------
           0 | 0 |   1
           0 | 1 |   0
           1 | 0 |   0
           1 | 1 |   1
       
      Since:
      0.6-riddler
    • XNOR

      public static final Function XNOR
      Logical function XNOR
           a | b | !(a^b)
           --+---+-------
           0 | 0 |   1
           0 | 1 |   0
           1 | 0 |   0
           1 | 1 |   1
       
      Since:
      0.6-riddler
    • FALSE

      public static final Function FALSE
      Boolean value false -> 0.0.
      Since:
      0.6-riddler
    • TRUE

      public static final Function TRUE
      Boolean value true -> 1.0.
      Since:
      0.6-riddler
  • Method Details