18 #if !defined(COSA_IOSTREAM_STDLIB_DTOA) 19 #include <avr/pgmspace.h> 35 static const unsigned long digits10[]
__PROGMEM = {
48 static const char letters[]
__PROGMEM =
"0123456789abcdef";
53 unsigned char i, j, k, l, first;
62 p = ((uint8_t*) &__val) +
sizeof(__val) - 1;
63 for (i = 0; i < 4 && *p == 0; i++, p--)
66 for (l = 0; l < 8; l++) {
70 for (; i < 4; i++, l = 0, k = *p--) {
72 __s[j++] = (k & 0x80) ?
'1' :
'0';
77 else if (base == 16) {
80 p = ((uint8_t*) &__val) +
sizeof(__val) - 1;
81 for (i = 0; i < 4 && *p == 0; i++, p--)
84 if (k & 0xf0) __s[j++] = pgm_read_byte(letters + (k >> 4));
85 __s[j++] = pgm_read_byte(letters + (k & 0xf));
86 for (i++; i < 4; i++) {
88 __s[j++] = pgm_read_byte(letters + (k >> 4));
89 __s[j++] = pgm_read_byte(letters + (k & 0xf));
93 const unsigned long *d;
96 max =
sizeof(digits8) /
sizeof(
unsigned long);
100 max =
sizeof(digits10) /
sizeof(
unsigned long);
103 for (i = 0; i < max; i++) {
104 unsigned long check = pgm_read_dword(d + i);
112 while(check <= __val) {
116 __s[j++] = pgm_read_byte(letters + k);
131 if (__val >= 0 || base != 10)
132 return (
ultoa((
unsigned long)__val, __s, base));
134 return (
ultoa((
unsigned long)(-__val), __s + 1, base) - 1);
140 return (
ultoa(((
unsigned long) __val) & 0xffff, __s, base));
146 return (
ltoa((
long)__val, __s, base));
static char * ltoa(long __val, char *__s, int base)
static const unsigned long digits8[] __PROGMEM
static char * itoa(int __val, char *__s, int base)
static char * utoa(unsigned int __val, char *__s, int base)
static char * ultoa(unsigned long __val, char *__s, int base)