SplitScript reference / Signed / abs

Signed.abs

Method

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

Returns this value without a negative sign.

Floating-point negative zero becomes positive zero and NaN remains NaN. Signed-integer arithmetic follows the language's wrapping rule, so the minimum value of an integer type remains itself because its positive counterpart is not representable in that type.

Effects: pure

Runtime behavior: available everywhere; synchronous

Examples

Measure the magnitude of a signed delta

let distance = (-12i32).abs()