4 #include "base/cl_sysdep.h"
14 // We don't use `stream << x' or `stream << dec << x', because an ostream
15 // carries so many attributes, and we don't want to modifies these attributes.
17 static void fprintdecimal_impl (std::ostream& stream, uintptr_t x)
19 #define bufsize (((sizeof(uintptr_t)*53)/22)+1) // 53/22 > 8*log(2)/log(10)
20 var char buf[bufsize+1];
21 var char* bufptr = &buf[bufsize];
29 fprint(stream,bufptr);
33 static void fprintdecimal_impl (std::ostream& stream, intptr_t x)
36 fprintdecimal(stream,(uintptr_t)x);
38 fprintchar(stream,'-');
39 fprintdecimal(stream,(uintptr_t)(-1-x)+1);
43 void fprintdecimal (std::ostream& stream, unsigned int x)
45 fprintdecimal_impl(stream,(uintptr_t)x);
47 void fprintdecimal (std::ostream& stream, int x)
49 fprintdecimal_impl(stream,(intptr_t)x);
52 void fprintdecimal (std::ostream& stream, unsigned long x)
54 fprintdecimal_impl(stream,(uintptr_t)x);
56 void fprintdecimal (std::ostream& stream, long x)
58 fprintdecimal_impl(stream,(intptr_t)x);
61 void fprintdecimal (std::ostream& stream, unsigned long long x)
63 #if long_long_bitsize <= pointer_bitsize
64 fprintdecimal_impl(stream,(uintptr_t)x);
66 #define bufsize (((sizeof(unsigned long long)*53)/22)+1) // 53/22 > 8*log(2)/log(10)
67 var char buf[bufsize+1];
68 var char* bufptr = &buf[bufsize];
71 unsigned long long q = x / 10;
72 unsigned long long r = x % 10;
76 fprint(stream,bufptr);
81 void fprintdecimal (std::ostream& stream, long long x)
83 #if long_long_bitsize <= pointer_bitsize
84 fprintdecimal_impl(stream,(intptr_t)x);
87 fprintdecimal(stream,(unsigned long long)x);
89 fprintchar(stream,'-');
90 fprintdecimal(stream,(unsigned long long)(-1-x)+1);