~ (object -- invertedValue)

Inputs

Outputs

For Cond, it performs logical NOT. For Whole objects, it performs bitwise complement. Arithmetic negation is provided by neg.

Behavior

Example: ~ on Cond, Nat8, and Int32

~ negates a Cond and complements the bits of Nat8 and Int32 values, so 0xF0n8 becomes 15n8 and 5 becomes -6, and an unknown operand gives an unknown result.

{} () {} [
  "-- cond --" printCompilerMessage
  TRUE ~ printStack _:;
  FALSE ~ printStack _:;
  unknownCond: FALSE dynamic;
  unknownCond ~ printStack _:;

  "-- nat8 --" printCompilerMessage
  0n8 ~ printStack _:;
  0xF0n8 ~ printStack _:;

  "-- int32 --" printCompilerMessage
  5 ~ printStack _:;
  -1 ~ printStack _:;
  unknownInt: 0 dynamic;
  unknownInt ~ printStack _:;
] "main" exportFunction

Expected Output During Compilation

-- cond --
FALSE
TRUE
Cond
-- nat8 --
255n8
15n8
-- int32 --
-6
0
Int32

See also