code: protected static float truncate(float f, int decimalPlaces) {
          float decimalShift = (float) Math.pow(10, decimalPlaces);
          return Math.round(f * decimalShift) / decimalShift;
      }
docs: Truncates a float number {@code f} to {@code decimalPlaces}.
  @param f the number to be truncated.
  @param decimalPlaces the amount of decimals that {@code f}
  will be truncated to.
  @return a truncated representation of {@code f}.