MCPcopy Create free account
hub / github.com/WheretIB/nullc / WriteLongConsole

Function WriteLongConsole

NULLC/includes/io.cpp:41–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39 }
40
41 void WriteLongConsole(long long number, int base)
42 {
43 InitConsole();
44 if(!(base > 1 && base <= 16))
45 {
46 nullcThrowError("incorrect base %d", base);
47 return;
48 }
49
50 static char symb[] = "0123456789abcdef";
51 bool sign = 0;
52 char buf[128];
53 char *curr = buf;
54 if(number < 0)
55 sign = 1;
56
57 *curr++ = *(abs(number % base) + symb);
58 while(number /= base)
59 *curr++ = *(abs(number % base) + symb);
60 if(sign)
61 *curr++ = '-';
62 *curr = 0;
63 int size = int(curr - buf), halfsize = size >> 1;
64 for(int i = 0; i < halfsize; i++)
65 {
66 char tmp = buf[i];
67 buf[i] = buf[size-i-1];
68 buf[size-i-1] = tmp;
69 }
70 printf("%s", buf);
71 }
72
73 void WriteIntConsole(int number, int base)
74 {

Callers 1

WriteIntConsoleFunction · 0.85

Calls 3

InitConsoleFunction · 0.85
absFunction · 0.70
nullcThrowErrorFunction · 0.50

Tested by

no test coverage detected