OPERATORS: LOGIC AND BITS

An operator is a sign that works on the values beside it: + adds, < compares, ! turns true into false. This post gathers satellite’s operators in one place. It shows what each one does today, and what satl says when you reach for one that is not built yet.

One rule covers every operator that sits between two values: write a space on both sides. 4 + 3 works, and 4+3 is refused.

Arithmetic

These work on numbers, and on the other number types where their own posts say so:

  • + - * / %: add, take away, multiply, divide, remainder
  • ^ raises to a power, and ** is its second spelling

/ between two whole numbers keeps the whole part, so 7 / 2 is 3. NUMBERS has the details.

Comparison

Six operators compare two values, and each one answers true or false:

  • == equal, and != not equal
  • < less than, and > greater than
  • <= less than or equal, and >= greater than or equal

They compare values of the same kind, and a few kinds that belong together: a whole number with a float, and a binary or hex with a number, by what they are worth. Strings put themselves in order with < and > too. A true or false value, and a color, have only == and !=. Two kinds that do not belong together, such as a number and a string, are refused rather than guessed at.

compare.satlSATELLITE 004 Download
Comparisons answer true or false
satellite.include(satellite)

satellite.capsule satellite.main()
{
    satellite.variable.number age = 12
    satellite.console.display(age >= 12)
    satellite.console.display(age != 12)
    satellite.console.display(3 < 3.5)
    satellite.console.display(1 == 1.0)
    satellite.console.display(b1010 == xA)
    satellite.console.display("apple" < "banana")
    satellite.variable.bool grown_up = age > 17
    satellite.console.display(grown_up)
    satellite.console.display(grown_up == satellite.bool.false)
    satellite.return(satellite)
}
OUTPUT
true
false
true
true
true
true
false
true

A comparison’s answer can be kept in a satellite.variable.bool, as grown_up is, and used later in an if or a while.

Logic: not, and, or

! in front of a true or false value turns it round: !(3 >= 4) is true. It works only on a true or false, so !5 is refused.

The two other logic operators, && (and) and || (or), are not built yet. Until they are, “and” is one if inside another, and “or” is a series of tests where any one can make a value true:

ticket.satlSATELLITE 004 Download
Not, and an "and" and an "or" written with if
satellite.include(satellite)

satellite.capsule satellite.main()
{
    satellite.variable.number age = 70
    satellite.variable.bool has_ticket = satellite.bool.true

    satellite.statement.if (!has_ticket)
    {
        satellite.console.display("buy a ticket first")
    }

    // and: both must be true
    satellite.statement.if (has_ticket)
    {
        satellite.statement.if (age >= 18)
        {
            satellite.console.display("welcome aboard")
        }
    }

    // or: either one is enough
    satellite.variable.bool discount = satellite.bool.false
    satellite.statement.if (age < 16)
    {
        discount = satellite.bool.true
    }
    satellite.statement.if (age >= 65)
    {
        discount = satellite.bool.true
    }
    satellite.statement.if (discount)
    {
        satellite.console.display("half price")
    }
    satellite.return(satellite)
}
OUTPUT
welcome aboard
half price

Bits

The bit operators, & (and), | (or), ~ (not), << (shift left) and >> (shift right), are not built yet, and neither are the methods .and(), .or() and .xor(). satl refuses each of them today. Here is .and(), refused before the program starts:

bits.satlSATELLITE 004 Download
Bit operations are not built yet
satellite.include(satellite)

satellite.capsule satellite.main()
{
    satellite.variable.binary mask = b1100
    satellite.console.display(mask.and(b1010))
    satellite.return(satellite)
}
OUTPUT
--------------------------------------------------------------------------------
SATELLITE CRITICAL ERROR REPORT
--------------------------------------------------------------------------------
S110: LINE_NOT_UNDERSTOOD
satl(check): in satellite.main, mask is satellite.variable.binary, and and is
not one of its methods -- only an object of a satellite.spacesuit has capsules
to call

directory: bits.satl:6
syntax: satellite.console.display(mask.and(b1010))
        /\

satellite has no scenario for this line -- it is spelled in a shape the language
does not have a meaning for.
machine code 13 satl_line_not_understood -- satl exits with this.

--------------------------------------------------------------------------------

What does work on bits today is reading them: a binary’s .number, .hex and .reverse(), and a number’s .binary. See BINARY AND HEXADECIMAL.

What + does with each kind

+ means something different for each kind of value, and satellite never converts one kind into another behind your back. When two kinds do not go together, + is refused, and for text and a number the report names the conversion to write.

plus.satlSATELLITE 004 Download
One sign, several meanings
satellite.include(satellite)

satellite.capsule satellite.main()
{
    satellite.variable.number score = 87
    satellite.console.display(40 + 2)
    satellite.console.display("sun" + "flower")
    satellite.console.display(1.5 + 2)
    satellite.console.display(b1100 + xFF)
    satellite.console.display(200 + 50%)
    satellite.console.display(50% + 25%)
    satellite.console.display("score: " + score.string)
    satellite.return(satellite)
}
OUTPUT
42
sunflower
3.5
267
300
75%
score: 87

Two numbers add, and two strings join. A float and a whole number add to a float. A binary and a hex add by what they are worth and answer a number. A number grows by a percentage, and two percentages add to a percentage. To put a number into text, say so with .string: "score: " + score on its own is refused with S301.

Where next

The FULL REFERENCE lists every operator. Conditions at work are in IF, WHILE AND FOR, and text and conversions are in STRINGS.

You may also like...

1 Response

  1. September 24, 2026

    […] yet, and neither are the bit operators (&, |, ~, <<, >>) or .width on a binary. OPERATORS: LOGIC AND BITS shows what satl says when you try […]

Leave a Reply

Your email address will not be published. Required fields are marked *