abs


Description:

[ CCode ( cname = "abs" ) ]
public int abs ()

Computes the absolute value

Example: Compute the absolute value:

public static int main (string[] args) {
// Output:
// ``10``
// ``99``
// ``1``
// ``9``
print ("%d\n", 10.abs ());
print ("%d\n", 99.abs ());
print ("%d\n", (-1).abs ());
print ("%d\n", (-9).abs ());

return 0;
}

valac --pkg glib-2.0 int.abs.vala

Returns:

The absolute value