HyperMath

Boolean

Boolean

Previous topic Next topic No expanding text in this topic  

Boolean

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

Boolean values have either the value true or false.  If a value is not true, it must be false and vice versa.  The not operator can be placed before a Boolean value to invert it.  In other words, not true is equal to false.

    > x = true

    > print(x)

    true

    > print(not x)

    false

    > print(not false)

    true

Boolean values are used to represent the results of logic tests.  The equals, ==, and not equals, ~=, operators return Boolean values depending on the values supplied to them.

    > print(5 == 6) // test whether two numbers are equal

    false

 

    x = 7.75;

    if (x == 5) then

   print("The value of x is:",x)

    else

   print("The value of x is:",x)

    end

    > The value of x is:    7.75

 

    > print(3 ~= 7) // test whether two numbers are not equal

    true

 

    > print(true ~= false) // is true not equal to false?

    true

1 and 0 equate to true and false, respectively.

 > print(1 == true)

 true

 > print(1 == false)

 false

Other numbers are not equated to either true or false.

> print(2 == true)

false

> print(2 == false)

false