SplitScript reference / Signed / negate

Signed.negate

Operator

T.negate() -> T where T: Signed

Returns this value with its sign inverted.

This method is also the implementation of unary -. Integer minimum values wrap to themselves, matching WebAssembly integer subtraction; floating-point values toggle their sign bit, including zero and NaN.

Effects: pure

Runtime behavior: available everywhere; synchronous

Examples

Invert a signed offset

let reverseOffset = -20i32