1diff --git a/include/strings.h b/include/strings.h 2index 00e7c5d..3b9bb5a 100644 3--- a/include/strings.h 4+++ b/include/strings.h 5@@ -33,12 +33,6 @@ static const int kFastToBufferSize = 48; 6 // Populates the provided buffer with an ASCII representation of the number. 7 char* FastInt32ToBufferLeft(int32_t i, char* buffer); 8 9-// Populates the provided buffer with ASCII representation of the float number. 10-// Avoids the use of any floating point instructions (since these aren't 11-// supported on many microcontrollers) and as a consequence prints values with 12-// power-of-two exponents. 13-char* FastFloatToBufferLeft(float i, char* buffer); 14- 15 // Appends a string to a string, in-place. You need to pass in the maximum 16 // string length as the second argument. 17 char* StrCatStr(char* main, int main_max_length, char* to_append); 18diff --git a/source/strings.c b/source/strings.c 19index 4701d35..10d5137 100644 20--- a/source/strings.c 21+++ b/source/strings.c 22@@ -55,63 +55,6 @@ char* FastInt32ToBufferLeft(int32_t i, char* buffer) { 23 return FastUInt32ToBufferLeft(u, buffer, 10); 24 } 25 26-// Populates the provided buffer with ASCII representation of the float number. 27-// Avoids the use of any floating point instructions (since these aren't 28-// supported on many microcontrollers) and as a consequence prints values with 29-// power-of-two exponents. 30-char* FastFloatToBufferLeft(float i, char* buffer) { 31- char* current = buffer; 32- char* current_end = buffer + (kFastToBufferSize - 1); 33- // Access the bit fields of the floating point value to avoid requiring any 34- // float instructions. These constants are derived from IEEE 754. 35- const uint32_t sign_mask = 0x80000000; 36- const uint32_t exponent_mask = 0x7f800000; 37- const int32_t exponent_shift = 23; 38- const int32_t exponent_bias = 127; 39- const uint32_t fraction_mask = 0x007fffff; 40- const uint32_t u = *(uint32_t*)(&i); 41- const int32_t exponent = 42- ((u & exponent_mask) >> exponent_shift) - exponent_bias; 43- const uint32_t fraction = (u & fraction_mask); 44- // Expect ~0x2B1B9D3 for fraction. 45- if (u & sign_mask) { 46- *current = '-'; 47- current += 1; 48- } 49- *current = 0; 50- // These are special cases for infinities and not-a-numbers. 51- if (exponent == 128) { 52- if (fraction == 0) { 53- current = StrCatStr(current, (current_end - current), "Inf"); 54- return current; 55- } else { 56- current = StrCatStr(current, (current_end - current), "NaN"); 57- return current; 58- } 59- } 60- // 0x007fffff represents 0.99... for the fraction, so to print the correct 61- // decimal digits we need to scale our value before passing it to the 62- // conversion function. This scale should be 10000000/8388608 = 1.1920928955. 63- // We can approximate this using multipy-adds and right-shifts using the 64- // values in this array. 65- const int32_t scale_shifts_size = 13; 66- const int8_t scale_shifts[13] = {3, 4, 8, 11, 13, 14, 17, 67- 18, 19, 20, 21, 22, 23}; 68- uint32_t scaled_fraction = fraction; 69- for (int i = 0; i < scale_shifts_size; ++i) { 70- scaled_fraction += (fraction >> scale_shifts[i]); 71- } 72- *current = '1'; 73- current += 1; 74- *current = '.'; 75- current += 1; 76- *current = 0; 77- current = StrCatUInt32(current, (current_end - current), scaled_fraction, 10); 78- current = StrCatStr(current, (current_end - current), "*2^"); 79- current = StrCatInt32(current, (current_end - current), exponent); 80- return current; 81-} 82- 83 // Appends a string to a string, in-place. You need to pass in the maximum 84 // string length as the second argument. 85 char* StrCatStr(char* main, int main_max_length, char* to_append) { 86