code: boolean fitsIntoLong(boolean isPositive, boolean ignoreNegativeZero) {
          // Figure out if the result will fit in a long.  We have to
          // first look for nonzero digits after the decimal point;
          // then check the size.  If the digit count is 18 or less, then
          // the value can definitely be represented as a long.  If it is 19
          // then it may be too large.
  
          // Trim trailing zeros.  This does not change the represented value.
          while (count > 0 && digits[count - 1] == '0') {
              --count;
          }
  
          if (count == 0) {
              // Positive zero fits into a long, but negative zero can only
              // be represented as a double. - bug 4162852
              return isPositive || ignoreNegativeZero;
          }
  
          if (decimalAt < count || decimalAt > MAX_COUNT) {
              return false;
          }
  
          if (decimalAt < MAX_COUNT) return true;
  
          // At this point we have decimalAt == count, and count == MAX_COUNT.
          // The number will overflow if it is larger than 9223372036854775807
          // or smaller than -9223372036854775808.
          for (int i=0; i<count; ++i) {
              char dig = digits[i], max = LONG_MIN_REP[i];
              if (dig > max) return false;
              if (dig < max) return true;
          }
  
          // At this point the first count digits match.  If decimalAt is less
          // than count, then the remaining digits are zero, and we return true.
          if (count < decimalAt) return true;
  
          // Now we have a representation of Long.MIN_VALUE, without the leading
          // negative sign.  If this represents a positive value, then it does
          // not fit; otherwise it fits.
          return !isPositive;
      }
docs: Return true if the number represented by this object can fit into
  a long.
  @param isPositive true if this number should be regarded as positive
  @param ignoreNegativeZero true if -0 should be regarded as identical to
  +0; otherwise they are considered distinct
  @return true if this number fits into a Java long