imaxabs

任意のサイズの整数の絶対値を計算します。

構文

intmax_t imaxabs(
   intmax_t n
);

パラメーター

n
整数値。

戻り値

imaxabs 関数は、引数の絶対値を返します。 エラーの戻り値はありません。

Note

使用 intmax_t して表すことができる負の整数の範囲は、表すことができる正の整数の範囲よりも大きいため、変換できない引数を imaxabs 指定できます。 引数の絶対値を戻り値の型で表すことができない場合、imaxabs の動作は未定義です。

必要条件

ルーチンによって返される値 必須ヘッダー
imaxabs <inttypes.h>

互換性の詳細については、「 Compatibility」を参照してください。

ライブラリ

C ランタイム ライブラリのすべてのバージョン。

// crt_imaxabs.c
// Build using: cl /W3 /Tc crt_imaxabs.c
// This example calls imaxabs to compute an
// absolute value, then displays the results.

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

int main(int argc, char *argv[])
{
   intmax_t x = LLONG_MIN + 2;

   printf("The absolute value of %lld is %lld\n", x, imaxabs(x));
}
The absolute value of -9223372036854775806 is 9223372036854775806

関連項目

データ変換
数学と浮動小数点のサポート
abs, labs, llabs, _abs64
_cabs
fabs, fabsf, fabsl