~ (object -- invertedValue)
Inputs
Outputs
invertedValue: Inverted object in the same schema.
For Cond, it performs logical NOT. For Whole objects, it performs bitwise complement. Arithmetic negation is provided by neg.
Behavior
- On Cond, the effect is equivalent to
xorwithTRUE. - On Nat and Int, the effect is equivalent to
xorwith the all-bits-set value of the same schema. - The flipped bit pattern is interpreted again as the same schema. In Int32,
5 ~therefore produces-6. - If the input object is not known at compile time, the builtin produces an unknown result of the same schema.
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
andbuiltin(leftOperand rightOperand -- combinedValue)Combines two Cond or Whole objects with bitwise or logical AND semantics.lshiftbuiltin(object shiftCount -- shiftedValue)Performs a bitwise left shift on a Whole object and keeps the same schema.orbuiltin(leftOperand rightOperand -- combinedValue)Combines two Cond or Whole objects with bitwise or logical OR semantics.rshiftbuiltin(object shiftCount -- shiftedValue)Performs a bitwise right shift on a Whole object and keeps the same schema.xorbuiltin(leftOperand rightOperand -- combinedValue)Combines two Cond or Whole objects with logical exclusive-OR or bitwise XOR semantics.