t2:abs

abs


abs - Absolute value

Description


int32 abs(int32 num);
fix32 abs(fix32 num);

Returns the absolute value of num.

Parameters


  • num: The numeric value to process.

Return Value


The absolute value of num. If the argument number is of type fix32, the return type is also fix32, otherwise it is integer.

Examples


Example #1 abs() example

init {
    printf("%.1f", abs(-4.2)); // 4.2 (fix32)
    printf("%d", abs(5));      // 5 (integer)
    printf("%d", abs(-5));     // 5 (integer)
}

See Also


t2/abs.txt · Last modified: 2017/06/28 04:17 by J2Kbr