private double completeCalculation() { if (charsIndex == 0 || (charsIndex == 1 && chars[0] == '-')) { // "" or "-" strictError(); // Strict requires at least one digit. return 0.0; // Treated as 0.0 (not -0.0) in non-strict. } else if (isExponent((byte) chars[charsIndex - 1])) { // Covers 12.0efrog strictError(); addExponentToResult(adjustExponent); } else if (isStrict && !isEOS()) { strictError(); // We know it is not whitespace at this point } else if (!wroteExponent && adjustExponent != 0) { addToResult((byte) 'E'); addExponentToResult(adjustExponent); } return SafeDoubleParser.parseDouble(new String(chars, 0, charsIndex)); }
private double completeCalculation() { if (charsIndex == 0 || (charsIndex == 1 && chars[0] == '-')) { // "" or "-" strictError(); // Strict requires at least one digit. return 0.0; // Treated as 0.0 (not -0.0) in non-strict. } else if (isExponent((byte) chars[charsIndex - 1])) { // Covers 12.0efrog strictError(); addExponentToResult(adjustExponent); } else if (isStrict && !isEOS()) { strictError(); // We know it is not whitespace at this point } else if (!wroteExponent && adjustExponent != 0) { addToResult((byte) 'E'); addExponentToResult(adjustExponent); } return SafeDoubleParser.parseDouble(new String(chars, 0, charsIndex)); }
private double completeCalculation() { if (charsIndex == 0 || (charsIndex == 1 && chars[0] == '-')) { // "" or "-" strictError(); // Strict requires at least one digit. return 0.0; // Treated as 0.0 (not -0.0) in non-strict. } else if (isExponent((byte) chars[charsIndex - 1])) { // Covers 12.0efrog strictError(); addExponentToResult(adjustExponent); } else if (isStrict && !isEOS()) { strictError(); // We know it is not whitespace at this point } else if (!wroteExponent && adjustExponent != 0) { addToResult((byte) 'E'); addExponentToResult(adjustExponent); } return SafeDoubleParser.parseDouble(new String(chars, 0, charsIndex)); }
/** * Consume initial whitespace and underscores so that next character * examined is not whitespace. 1.9 and strict do not allow leading * underscores. Returns whether next position is at the end of the * string or not. * * Trivia: " _ _ _ _ 1".to_f == 1.0 in Ruby 1.8 */ private boolean skipWhitespace() { while (!isEOS()) { byte value = next(); if (isWhitespace(value)) continue; if (value != '_' || isStrict || is19) return previous(); } return true; }
/** * Consume initial whitespace and underscores so that next character * examined is not whitespace. 1.9 and strict do not allow leading * underscores. Returns whether next position is at the end of the * string or not. * * Trivia: " _ _ _ _ 1".to_f == 1.0 in Ruby 1.8 */ private boolean skipWhitespace() { while (!isEOS()) { byte value = next(); if (isWhitespace(value)) continue; if (value != '_' || isStrict || is19) return previous(); } return true; }
private double completeCalculation() { if (charsIndex == 0 || (charsIndex == 1 && chars[0] == '-')) { // "" or "-" strictError(); // Strict requires at least one digit. return 0.0; // Treated as 0.0 (not -0.0) in non-strict. } else if (isExponent((byte) chars[charsIndex - 1])) { // Covers 12.0efrog strictError(); addExponentToResult(adjustExponent); } else if (isStrict && !isEOS()) { strictError(); // We know it is not whitespace at this point } else if (!wroteExponent && adjustExponent != 0) { addToResult((byte) 'E'); addExponentToResult(adjustExponent); } return SafeDoubleParser.parseDouble(new String(chars, 0, charsIndex)); }
/** * Consume initial whitespace and underscores so that next character * examined is not whitespace. 1.9 and strict do not allow leading * underscores. Returns whether next position is at the end of the * string or not. * * Trivia: " _ _ _ _ 1".to_f == 1.0 in Ruby 1.8 */ private boolean skipWhitespace() { while (!isEOS()) { byte value = next(); if (isWhitespace(value)) continue; return previous(); } return true; }
/** * Consume initial whitespace and underscores so that next character * examined is not whitespace. 1.9 and strict do not allow leading * underscores. Returns whether next position is at the end of the * string or not. * * Trivia: " _ _ _ _ 1".to_f == 1.0 in Ruby 1.8 */ private boolean skipWhitespace() { while (!isEOS()) { byte value = next(); if (isWhitespace(value)) continue; return previous(); } return true; }
private void verifyNumberAfterUnderscore() { if (isStrict && (isEOS() || !isDigit(bytes[index]))) { strictError(); } } }
private void verifyNumberAfterUnderscore() { if (isStrict && (isEOS() || !isDigit(bytes[index]))) { strictError(); } } }
private boolean parseOptionalSign() { byte sign = next(); if (sign == '-') { addToResult(sign); } else if (sign != '+') { previous(); // backup...not a sign-char } return isEOS(); }
private void verifyNumberAfterUnderscore() { if (isStrict && (isEOS() || !isDigit(bytes[index]))) { strictError(); } } }
private boolean parseOptionalSign() { byte sign = next(); if (sign == '-') { addToResult(sign); } else if (sign != '+') { previous(); // backup...not a sign-char } return isEOS(); }
private boolean parseOptionalSign() { byte sign = next(); if (sign == '-') { addToResult(sign); } else if (sign != '+') { previous(); // backup...not a sign-char } return isEOS(); }
private void verifyNumberAfterUnderscore() { if (isStrict && (isEOS() || !isDigit(bytes[index]))) { strictError(); } } }
private boolean parseOptionalSign() { byte sign = next(); if (sign == '-') { addToResult(sign); } else if (sign != '+') { previous(); // backup...not a sign-char } return isEOS(); }