1 // fprinthexadecimal().
4 #include "base/cl_sysdep.h"
14 void fprinthexadecimal_impl (std::ostream& stream, uintptr_t x)
16 #define bufsize (sizeof(uintptr_t)*2)
17 var char buf[bufsize+1];
18 var char* bufptr = &buf[bufsize];
23 *--bufptr = (r<10 ? '0'+r : 'A'-10+r);
26 fprint(stream,bufptr);
30 void fprinthexadecimal_impl (std::ostream& stream, intptr_t x)
33 fprintdecimal(stream,(uintptr_t)x);
35 fprintchar(stream,'-');
36 fprintdecimal(stream,(uintptr_t)(-1-x)+1);
40 #if defined(HAVE_LONGLONG) && (long_long_bitsize > pointer_bitsize)
42 void fprinthexadecimal (std::ostream& stream, unsigned long long x)
44 #define bufsize (sizeof(unsigned long long)*2)
45 var char buf[bufsize+1];
46 var char* bufptr = &buf[bufsize];
49 unsigned long long q = x / 16;
50 unsigned long long r = x % 16;
51 *--bufptr = (r<10 ? '0'+r : 'A'-10+r);
54 fprint(stream,bufptr);
58 void fprinthexadecimal (std::ostream& stream, long long x)
61 fprintdecimal(stream,(unsigned long long)x);
63 fprintchar(stream,'-');
64 fprintdecimal(stream,(unsigned long long)(-1-x)+1);