public static boolean fits (int val, int bits) {
public static boolean fits (long val, int bits) {
  public static boolean fits (int val, int bits) {    val = val >> bits - 1;    return  (val == 0 || val == -1);  }