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