3 /* 7.8 Format conversion of integer types <inttypes.h>
5 This file is part of the Public Domain C Library (PDCLib).
6 Permission is granted to use, modify, and / or redistribute at will.
9 #ifndef _PDCLIB_INTTYPES_H
10 #define _PDCLIB_INTTYPES_H _PDCLIB_INTTYPES_H
14 typedef struct _PDCLIB_imaxdiv_t imaxdiv_t;
16 /* TODO: Print / Scan Macros */
18 PRId8 PRIdLEAST8 PRIdFAST8 PRIdMAX
19 PRId16 PRIdLEAST16 PRIdFAST16 PRIdPTR
20 PRId32 PRIdLEAST32 PRIdFAST32
21 PRId64 PRIdLEAST64 PRIdFAST64
23 PRIi8 PRIiLEAST8 PRIiFAST8 PRIiMAX
24 PRIi16 PRIiLEAST16 PRIiFAST16 PRIdPTR
25 PRIi32 PRIiLEAST32 PRIiFAST32
26 PRIi64 PRIiLEAST64 PRIiFAST64
28 PRIo8 PRIoLEAST8 PRIoFAST8 PRIoMAX
29 PRIo16 PRIoLEAST16 PRIoFAST16 PRIoPTR
30 PRIo32 PRIoLEAST32 PRIoFAST32
31 PRIo64 PRIoLEAST64 PRIoFAST64
33 PRIu8 PRIuLEAST8 PRIuFAST8 PRIuMAX
34 PRIu16 PRIuLEAST16 PRIuFAST16 PRIuPTR
35 PRIu32 PRIuLEAST32 PRIuFAST32
36 PRIu64 PRIuLEAST64 PRIuFAST64
38 PRIx8 PRIxLEAST8 PRIxFAST8 PRIxMAX
39 PRIx16 PRIxLEAST16 PRIxFAST16 PRIxPTR
40 PRIx32 PRIxLEAST32 PRIxFAST32
41 PRIx64 PRIxLEAST64 PRIxFAST64
43 PRIX8 PRIXLEAST8 PRIXFAST8 PRIXMAX
44 PRIX16 PRIXLEAST16 PRIXFAST16 PRIXPTR
45 PRIX32 PRIXLEAST32 PRIXFAST32
46 PRIX64 PRIXLEAST64 PRIXFAST64
48 SCNd8 SCNdLEAST8 SCNdFAST8 SCNdMAX
49 SCNd16 SCNdLEAST16 SCNdFAST16 SCNdPTR
50 SCNd32 SCNdLEAST32 SCNdFAST32
51 SCNd64 SCNdLEAST64 SCNdFAST64
53 SCNi8 SCNiLEAST8 SCNiFAST8 SCNiMAX
54 SCNi16 SCNiLEAST16 SCNiFAST16 SCNdPTR
55 SCNi32 SCNiLEAST32 SCNiFAST32
56 SCNi64 SCNiLEAST64 SCNiFAST64
58 SCNo8 SCNoLEAST8 SCNoFAST8 SCNoMAX
59 SCNo16 SCNoLEAST16 SCNoFAST16 SCNoPTR
60 SCNo32 SCNoLEAST32 SCNoFAST32
61 SCNo64 SCNoLEAST64 SCNoFAST64
63 SCNu8 SCNuLEAST8 SCNuFAST8 SCNuMAX
64 SCNu16 SCNuLEAST16 SCNuFAST16 SCNuPTR
65 SCNu32 SCNuLEAST32 SCNuFAST32
66 SCNu64 SCNuLEAST64 SCNuFAST64
68 SCNx8 SCNxLEAST8 SCNxFAST8 SCNxMAX
69 SCNx16 SCNxLEAST16 SCNxFAST16 SCNxPTR
70 SCNx32 SCNxLEAST32 SCNxFAST32
71 SCNx64 SCNxLEAST64 SCNxFAST64
73 SCNX8 SCNXLEAST8 SCNXFAST8 SCNXMAX
74 SCNX16 SCNXLEAST16 SCNXFAST16 SCNXPTR
75 SCNX32 SCNXLEAST32 SCNXFAST32
76 SCNX64 SCNXLEAST64 SCNXFAST64
79 /* 7.8.2 Functions for greatest-width integer types */
81 /* Calculate the absolute value of j */
82 intmax_t imaxabs( intmax_t j );
84 /* Return quotient (quot) and remainder (rem) of an integer division in the
87 imaxdiv_t imaxdiv( intmax_t numer, intmax_t denom );
89 /* Seperate the character array nptr into three parts: A (possibly empty)
90 sequence of whitespace characters, a character representation of an integer
91 to the given base, and trailing invalid characters (including the terminating
92 null character). If base is 0, assume it to be 10, unless the integer
93 representation starts with 0x / 0X (setting base to 16) or 0 (setting base to
94 8). If given, base can be anything from 0 to 36, using the 26 letters of the
95 base alphabet (both lowercase and uppercase) as digits 10 through 35.
96 The integer representation is then converted into the return type of the
97 function. It can start with a '+' or '-' sign. If the sign is '-', the result
98 of the conversion is negated.
99 If the conversion is successful, the converted value is returned. If endptr
100 is not a NULL pointer, a pointer to the first trailing invalid character is
102 If no conversion could be performed, zero is returned (and nptr in *endptr,
103 if endptr is not a NULL pointer). If the converted value does not fit into
104 the return type, the functions return INTMAX_MIN, INTMAX_MAX, or UINTMAX_MAX,
105 respectively, depending on the sign of the integer representation and the
106 return type, and errno is set to ERANGE.
108 /* This function is equivalent to strtol() / strtoul() in <stdlib.h>, but on
109 the potentially larger type.
111 intmax_t strtoimax( const char * _PDCLIB_restrict nptr, char * * _PDCLIB_restrict endptr, int base );
112 uintmax_t strtoumax( const char * _PDCLIB_restrict nptr, char * * _PDCLIB_restrict endptr, int base );
114 /* TODO: wcstoimax(), wcstoumax() */