当前位置: C语言 -- 标准库 -- <inttypes.h> -- imaxabs

imaxabs函数


概要:
#include <inttypes.h>
intmax_t imaxabs(intmax_t j);

描述:

该函数计算参数j的绝对值。如果结果无法表示(最小负数的绝对值不能使用二进制补码表示。),其行为是未定义的。


参数:
intmax_t j

参数为一个intmax_t类型的整数。


返回值:

函数返回参数j的绝对值。


范例:
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
/*函数imaxabs范例*/

#include <inttypes.h>
#include <stdio.h>

int main(void)
{
    intmax_t a = -5;

    printf("Absolute value of a:%jd.", imaxabs(a));

    return 0;
}

输出:

Absolute value of a:5.


相关内容:
imaxdiv 计算商和余数的函数。