~

~ (value -- invertedValue)

Inputs

Outputs

~ is unary: it consumes one value and returns one value of the same schema.

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

Behavior

Example

{} () {} [
  "-- 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