7.4.16 <inttypes.h>

Extends the integer types.

The following macros and functions are all implementation-defined.

Type

Definition Name

Description

Type
(macro)

Imaxdiv_t

Indicates the type of the value returned by the imaxdiv function.

Variable
(macro)

PRIdN

PRIdLEASTN

PRIdFASTN

PRIdMAX

PRIdPTR

PRIiN

PRIiLEASTN

PRIiFASTN

PRIiMAX

PRIiPTR

PRIoN

PRIoLEASTN

PRIoFASTN

PRIoMAX

PRIoPTR

PRIuN

PRIuLEASTN

PRIuFASTN

PRIuMAX

PRIuPTR

PRIxN

PRIxLEASTN

PRIxFASTN

PRIxMAX

PRIxPTR

PRIXN

PRIXLEASTN

PRIXFASTN

PRIXMAX

PRIXPTR

SCNdN

SCNdLEASTN

SCNdFASTN

SCNdMAX

SCNdPTR

SCNiN

SCNiLEASTN

SCNiFASTN

SCNiMAX

SCNiPTR

SCNoN

SCNoLEASTN

SCNoFASTN

SCNoMAX

SCNoPTR

SCNuN

SCNuLEASTN

SCNuFASTN

SCNuMAX

SCNuPTR

SCNxN

SCNxLEASTN

SCNxFASTN

SCNxMAX

SCNxPTR

 

Function

imaxabs

Calculates the absolute value.

imaxdiv

Calculates the quotient and remainder.

strtoimax

strtoumax

Equivalent to the strtol, strtoll, strtoul, and strtoull functions, except that the initial part of the string is converted to intmax_t and uintmax_t representation.

wcstoimax

wcstoumax

Equivalent to the wcstol, wcstoll, wcstoul, and wcstoull functions except that the initial part of the wide string is converted to intmax_t and uintmax_t representation.

 

imaxabs

Calculates the absolute value.

[Format]

#include <inttypes.h>
intmax_t imaxabs(intmax_t a);

[Parameters]

a Value for which the absolute value is to be computed

[Return values]

Absolute value of a

 

imaxdiv

Performs a division operation.

[Format]

#include <inttypes.h>
intmaxdiv_t imaxdiv(intmax_t n, intmax_t d);

[Parameters]

n Dividend and divisor

d

[Return values]

Division result consisting of the quotient and remainder

 

strtoimax/strtoumax

Converts a number-representing string to an intmax_t type integer.

[Format]

#include <inttypes.h>
intmax_t strtoimax( const char *nptr, char **endptr, long base);
uintmax_t strtoumax(const char *nptr, char **endptr, long base);

[Parameters]

nptr Pointer to a number-representing string to be converted

endptr Pointer to the storage area containing a pointer to the first character that does not represent an integer

base Radix of conversion (0 or 2 to 36)

[Return Values]

Normal: If the string pointed by nptr begins with a character that does not represent an integer: 0
If the string pointed by nptr begins with a character that represents an integer: Converted data as an intmax_t type integer

Abnormal: If the converted data overflows: INTMAX_MAX, INTMAX_MIN, or UINTMAX_MAX

[Remarks]

If the converted result overflows, ERANGE is set in errno.

The strtoimax and strtoumax functions are equivalent to the strtol, strtoll, strtoul, and strtoull functions except that the initial part of the string is respectively converted to intmax_t and uintmax_t integers.

 

wcstoimax/wcstoumax

Converts a number-representing string to an intmax_t or uintmax_t type integer.

[Format]

#include <stddef.h>
#include <inttypes.h>
intmax_t wcstoimax(const wchar_t * restrict nptr, wchar_t ** restrict endptr, long base);
uintmax_t wcstoumax(const wchar_t * restrict nptr, wchar_t ** restrict endptr, long base);


[Parameters]

nptr Pointer to a number-representing string to be converted

endptr Pointer to the storage area containing a pointer to the first character that does not represent an integer

base Radix of conversion (0 or 2 to 36)

[Return Values]

Normal: If the string pointed by nptr begins with a character that does not represent an integer: 0
If the string pointed by nptr begins with a character that represents an integer: Converted data as an intmax_t type integer

Abnormal: If the converted data overflows: INTMAX_MAX, INTMAX_MIN, or UINTMAX_MAX

[Remarks]

If the converted result overflows, ERANGE is set in errno.

The wcstoimax and wcstoumax functions are equivalent to the wcstol, wcstoll, wcstoul, and wcstoull functions, except that the initial part of the string is respectively converted to intmax_t and uintmax_t integers.