MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / longlong2str

Function longlong2str

src/PowerPC_EABI_Support/src/MSL_C/MSL_Common/printf.c:390–490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

388}
389
390static char* longlong2str(long long num, char* pBuf, print_format fmt)
391{
392 unsigned long long unsigned_num, base;
393 char* p;
394 int n, digits;
395 int minus = 0;
396 unsigned_num = num;
397 minus = 0;
398 p = pBuf;
399 *--p = 0;
400 digits = 0;
401
402 if (!num && !fmt.precision && !(fmt.alternate_form && fmt.conversion_char == 'o')) {
403 return p;
404 }
405
406 switch (fmt.conversion_char) {
407 case 'd':
408 case 'i':
409 base = 10;
410
411 if (num < 0) {
412 unsigned_num = -unsigned_num;
413 minus = 1;
414 }
415 break;
416 case 'o':
417 base = 8;
418 fmt.sign_options = only_minus;
419 break;
420 case 'u':
421 base = 10;
422 fmt.sign_options = only_minus;
423 break;
424 case 'x':
425 case 'X':
426 base = 16;
427 fmt.sign_options = only_minus;
428 break;
429 }
430
431 do {
432 n = unsigned_num % base;
433 unsigned_num /= base;
434
435 if (n < 10) {
436 n += '0';
437 } else {
438 n -= 10;
439 if (fmt.conversion_char == 'x') {
440 n += 'a';
441 } else {
442 n += 'A';
443 }
444 }
445
446 *--p = n;
447 ++digits;

Callers 1

__pformatterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected