Skip to main content

Define a Boolean

On/Off, 1/0, True/False. Lots of information comes in pairs. We call this data type a boolean. For simplicity, a boolean value can either be true or false, but you can use it to represent any type of data pair you want.

Boolean values

The keywords true and false are special in the Decipad Language because they represent boolean values. Take a look at these examples:

Example 1:

When you use the keywords true or false, they will return themselves since they represent a value.

Example 2:

The next time you need to represent something as On or Off, you can use a boolean data type!

Comparing values

Compare two values using comparison operators like this:

In this example, the comparison result is true.

The available comparison operators are as follows:

  • >: "greater than"
  • <: "less than"
  • >=: "greater than or equal to"
  • <=: "less than or equal to"
  • ==: "equals"
  • !=: "not equal to"

Parentheses

Use parentheses to chain operators and define priorities:

Parentheses are used to ensure that the / operation on the right side of the != is performed before the evaluation of the != itself.