Documentation Language: Swift

Function

abs(_:)

Returns the absolute value of a number.

func abs(_ value: any EcoreValue) throws -> any EcoreValue

Parameters

value

The numeric value to compute absolute value for

Return Value

The absolute value with the same type as input

Discussion

Computes the absolute value (magnitude) of the given numeric value. Follows OCL type rules: Integer→Integer, Real→Real.

Examples

let result1 = try abs(-5 as EInt)      // Result: 5 as EInt
let result2 = try abs(-3.14 as EDouble) // Result: 3.14 as EDouble