| 169 | // Print a number in a specified base (16, 8, 10 or 2 supported) |
| 170 | |
| 171 | void PrintInteger(bool typeUnsigned, uint64_t argu, int base, uint64_t numbits, |
| 172 | FormatterParams formatter, bool uppercaseDigits, char *&output, |
| 173 | size_t &actualsize, char *end) |
| 174 | { |
| 175 | int64_t argi = 0; |
| 176 | |
| 177 | union |
| 178 | { |
| 179 | uint64_t *u64; |
| 180 | signed int *i; |
| 181 | signed char *c; |
| 182 | signed short *s; |
| 183 | int64_t *i64; |
| 184 | } typepun; |
| 185 | |
| 186 | typepun.u64 = &argu; |
| 187 | |
| 188 | // cast the appropriate size to signed version |
| 189 | switch(formatter.Length) |
| 190 | { |
| 191 | default: |
| 192 | case None: |
| 193 | case Long: argi = (int64_t)*typepun.i; break; |
| 194 | case HalfHalf: argi = (int64_t)*typepun.c; break; |
| 195 | case Half: argi = (int64_t)*typepun.s; break; |
| 196 | case LongLong: argi = (int64_t)*typepun.i64; break; |
| 197 | #if ENABLED(RDOC_X64) |
| 198 | RDCCOMPILE_ASSERT(sizeof(size_t) == sizeof(int64_t), "64-bit macros are wrong"); |
| 199 | case SizeT: argi = (int64_t)*typepun.i64; break; |
| 200 | #else |
| 201 | RDCCOMPILE_ASSERT(sizeof(size_t) == sizeof(int32_t), "64-bit macros are wrong"); |
| 202 | case SizeT: argi = (int64_t)*typepun.i; break; |
| 203 | #endif |
| 204 | } |
| 205 | |
| 206 | bool negative = false; |
| 207 | if(base == 10 && !typeUnsigned) |
| 208 | { |
| 209 | negative = argi < 0; |
| 210 | } |
| 211 | |
| 212 | int digwidth = 0; |
| 213 | int numPad0s = 0; |
| 214 | int numPadWidth = 0; |
| 215 | { |
| 216 | int intwidth = 0; |
| 217 | int digits = 0; |
| 218 | |
| 219 | // work out the number of decimal digits in the integer |
| 220 | if(!negative) |
| 221 | { |
| 222 | uint64_t accum = argu; |
| 223 | while(accum) |
| 224 | { |
| 225 | digits += 1; |
| 226 | accum /= base; |
| 227 | } |
| 228 | } |
no test coverage detected