code: public static int formatFloat(final char[] formattedValue, float value, int endIndex, int digits, char separator) {
          if (digits >= POW10.length) {
              formattedValue[endIndex - 1] = '.';
              return 1;
          }
          boolean negative = false;
          if (value == 0) {
              formattedValue[endIndex - 1] = '0';
              return 1;
          }
          if (value < 0) {
              negative = true;
              value = -value;
          }
          if (digits > POW10.length) {
              digits = POW10.length - 1;
          }
          value *= POW10[digits];
          long lval = Math.round(value);
          int index = endIndex - 1;
          int charsNumber = 0;
          while (lval != 0 || charsNumber < (digits + 1)) {
              int digit = (int) (lval % 10);
              lval = lval / 10;
              formattedValue[index--] = (char) (digit + '0');
              charsNumber++;
              if (charsNumber == digits) {
                  formattedValue[index--] = separator;
                  charsNumber++;
              }
          }
          if (formattedValue[index + 1] == separator) {
              formattedValue[index--] = '0';
              charsNumber++;
          }
          if (negative) {
              formattedValue[index--] = '-';
              charsNumber++;
          }
          return charsNumber;
      }
docs: Formats a float value to the given number of decimals. Returns the length of the string. The string begins at
  [endIndex] - [return value] and ends at [endIndex]. It's up to you to check indexes correctness.
  Parameter [endIndex] can be helpful when you want to append some text to formatted value.
  
  @return number of characters of formatted value