// fprinthexadecimal(). // General includes. #include "base/cl_sysdep.h" // Specification. #include "cln/io.h" // Implementation. namespace cln { void fprinthexadecimal_impl (std::ostream& stream, uintptr_t x) { #define bufsize (sizeof(uintptr_t)*2) var char buf[bufsize+1]; var char* bufptr = &buf[bufsize]; *bufptr = '\0'; do { uintptr_t q = x / 16; uintptr_t r = x % 16; *--bufptr = (r<10 ? '0'+r : 'A'-10+r); x = q; } while (x > 0); fprint(stream,bufptr); #undef bufsize } void fprinthexadecimal_impl (std::ostream& stream, intptr_t x) { if (x >= 0) fprintdecimal(stream,(uintptr_t)x); else { fprintchar(stream,'-'); fprintdecimal(stream,(uintptr_t)(-1-x)+1); } } #if defined(HAVE_LONGLONG) && (long_long_bitsize > pointer_bitsize) void fprinthexadecimal (std::ostream& stream, unsigned long long x) { #define bufsize (sizeof(unsigned long long)*2) var char buf[bufsize+1]; var char* bufptr = &buf[bufsize]; *bufptr = '\0'; do { unsigned long long q = x / 16; unsigned long long r = x % 16; *--bufptr = (r<10 ? '0'+r : 'A'-10+r); x = q; } while (x > 0); fprint(stream,bufptr); #undef bufsize } void fprinthexadecimal (std::ostream& stream, long long x) { if (x >= 0) fprintdecimal(stream,(unsigned long long)x); else { fprintchar(stream,'-'); fprintdecimal(stream,(unsigned long long)(-1-x)+1); } } #endif } // namespace cln