in core/src/main/java/com/alibaba/fastjson2/JSONReaderUTF16.java [3634:3897]
public final void readNumber0() {
boolean valid = false;
this.wasNull = false;
this.mag0 = 0;
this.mag1 = 0;
this.mag2 = 0;
this.mag3 = 0;
this.negative = false;
this.exponent = 0;
this.scale = 0;
int firstOffset = offset;
final int end = this.end;
final char[] chars = this.chars;
char ch = this.ch;
int offset = this.offset;
char quote = '\0';
if (ch == '"' || ch == '\'') {
quote = ch;
ch = chars[offset++];
if (ch == quote) {
ch = offset == end ? EOI : chars[offset++];
while (ch <= ' ' && ((1L << ch) & SPACE) != 0) {
ch = offset == end ? EOI : chars[offset++];
}
this.ch = ch;
this.offset = offset;
comma = nextIfComma();
wasNull = true;
valueType = JSON_TYPE_NULL;
return;
}
}
final int start = offset;
final int multmin;
if (ch == '-') {
if (offset == end) {
throw new JSONException(info("illegal input"));
}
multmin = -214748364; // limit / 10;
negative = true;
ch = chars[offset++];
} else {
if (ch == '+') {
if (offset == end) {
throw new JSONException(info("illegal input"));
}
ch = chars[offset++];
}
multmin = -214748364; // limit / 10;
}
// if (result < limit + digit) {
boolean intOverflow = false;
valueType = JSON_TYPE_INT;
while (ch >= '0' && ch <= '9') {
valid = true;
if (!intOverflow) {
int digit = ch - '0';
mag3 *= 10;
if (mag3 < multmin) {
intOverflow = true;
} else {
mag3 -= digit;
if (mag3 < multmin) {
intOverflow = true;
}
}
}
if (offset == end) {
ch = EOI;
offset++;
break;
}
ch = chars[offset++];
}
if (ch == '.') {
valueType = JSON_TYPE_DEC;
ch = chars[offset++];
while (ch >= '0' && ch <= '9') {
valid = true;
if (!intOverflow) {
int digit = ch - '0';
mag3 *= 10;
if (mag3 < multmin) {
intOverflow = true;
} else {
mag3 -= digit;
if (mag3 < multmin) {
intOverflow = true;
}
}
}
this.scale++;
if (offset == end) {
ch = EOI;
offset++;
break;
}
ch = chars[offset++];
}
}
if (intOverflow) {
int numStart = negative ? start : start - 1;
int numDigits = scale > 0 ? offset - 2 - numStart : offset - 1 - numStart;
if (numDigits > 38) {
valueType = JSON_TYPE_BIG_DEC;
if (negative) {
numStart--;
}
stringValue = new String(chars, numStart, offset - 1 - numStart);
} else {
bigInt(chars, numStart, offset - 1);
}
} else {
mag3 = -mag3;
}
if (ch == 'e' || ch == 'E') {
boolean negativeExp = false;
int expValue = 0;
ch = chars[offset++];
if (ch == '-') {
negativeExp = true;
ch = chars[offset++];
} else if (ch == '+') {
ch = chars[offset++];
}
while (ch >= '0' && ch <= '9') {
valid = true;
int byteVal = (ch - '0');
expValue = expValue * 10 + byteVal;
if (expValue > MAX_EXP) {
throw new JSONException("too large exp value : " + expValue);
}
if (offset == end) {
ch = EOI;
break;
}
ch = chars[offset++];
}
if (negativeExp) {
expValue = -expValue;
}
this.exponent = (short) expValue;
valueType = JSON_TYPE_DEC;
}
if (offset == start) {
if (ch == 'n') {
if (chars[offset] == 'u'
&& chars[offset + 1] == 'l'
&& chars[offset + 2] == 'l'
) {
offset += 3;
valid = true;
wasNull = true;
valueType = JSON_TYPE_NULL;
ch = offset == end ? EOI : chars[offset++];
}
} else if (ch == 't' && chars[offset] == 'r' && chars[offset + 1] == 'u' && chars[offset + 2] == 'e') {
offset += 3;
valid = true;
boolValue = true;
valueType = JSON_TYPE_BOOL;
ch = offset == end ? EOI : chars[offset++];
} else if (ch == 'f' && offset + 3 < end && isALSE(chars, offset)) {
valid = true;
offset += 4;
boolValue = false;
valueType = JSON_TYPE_BOOL;
ch = offset == end ? EOI : chars[offset++];
} else if (ch == 'N' && chars[offset] == 'a' && chars[offset + 1] == 'N') {
offset += 2;
valid = true;
boolValue = true;
valueType = JSON_TYPE_NaN;
ch = offset == end ? EOI : chars[offset++];
} else if (ch == '{' && quote == 0) {
this.offset = offset;
this.ch = ch;
this.complex = readObject();
valueType = JSON_TYPE_OBJECT;
return;
} else if (ch == '[' && quote == 0) {
this.offset = offset;
this.ch = ch;
this.complex = readArray();
valueType = JSON_TYPE_ARRAY;
return;
}
}
if (quote != 0) {
if (ch != quote) {
this.offset = firstOffset;
this.ch = quote;
readString0();
valueType = JSON_TYPE_STRING;
return;
}
ch = offset == end ? EOI : chars[offset++];
}
if (ch == 'L' || ch == 'F' || ch == 'D' || ch == 'B' || ch == 'S') {
switch (ch) {
case 'B':
if (!intOverflow && valueType != JSON_TYPE_DEC) {
valueType = JSON_TYPE_INT8;
}
break;
case 'S':
if (!intOverflow && valueType != JSON_TYPE_DEC) {
valueType = JSON_TYPE_INT16;
}
break;
case 'L':
if (offset - start < 19 && valueType != JSON_TYPE_DEC) {
valueType = JSON_TYPE_INT64;
}
break;
case 'F':
valueType = JSON_TYPE_FLOAT;
break;
case 'D':
valueType = JSON_TYPE_DOUBLE;
break;
default:
break;
}
ch = offset == end ? EOI : chars[offset++];
}
while (ch <= ' ' && ((1L << ch) & SPACE) != 0) {
ch = offset == end ? EOI : chars[offset++];
}
if (comma = (ch == ',')) {
ch = offset == end ? EOI : chars[offset++];
while (ch <= ' ' && ((1L << ch) & SPACE) != 0) {
ch = offset == end ? EOI : chars[offset++];
}
}
if (!valid) {
throw new JSONException(info("illegal input error"));
}
this.offset = offset;
this.ch = ch;
}