code: private static String checkBufferSize(final String str) {
          // try to get value
          int nb_mega;
          try {
              nb_mega = Integer.parseInt(str);
          } catch (final NumberFormatException e) {
              return null;
          }
  
          // Compute the real size and the power of 2
          final long size = (long) nb_mega * 1024 * 1024;
          long l = size;
          int cnt;
          for (cnt = 0; l > 0; cnt++) {
              l >>= 1;
          }
          cnt--;
  
          // Check if number ob Mb is not power of 2
          if (Math.pow(2, cnt) < size) {
              cnt++;
          }
          System.out.println(nb_mega + " Mbytes  (2^" + cnt + ")");
  
          final int jacorb_size = cnt - 4;
          return Integer.toString(jacorb_size);
      }
docs: ===================================================================