code: public static int compare(Number a, Number b) 
    {
      int aType = getType(a);
      int bType = getType(b);
      
      int compType = (aType >= bType) ? aType : bType;
      switch (compType) 
      {
        case INT :
          int li = a.intValue();
          int ri = b.intValue();
          return (li < ri) ? -1 : (li == ri) ? 0 : 1;
        case LONG :
          long ll = a.longValue();
          long rl = b.longValue();
          return (ll < rl) ? -1 : (ll == rl) ? 0 : 1;
        case FLOAT :
          float lf = a.floatValue();
          float rf = b.floatValue();
          return (lf < rf) ? -1 : (lf == rf) ? 0 : 1;
        case DOUBLE :
          double ld = a.doubleValue();
          double rd = b.doubleValue();
          return (ld < rd) ? -1 : (ld == rd) ? 0 : 1;
        default :
          throw new IllegalStateException();
      }
    }
docs: Implement Number compare