Package org.jruby.util
Class ConvertDouble.DoubleConverter
java.lang.Object
org.jruby.util.ConvertDouble.DoubleConverter
- Enclosing class:
- ConvertDouble
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate byte[]private char[]private intprivate intprivate static final intprivate intprivate booleanprivate static final intprivate static final intprivate doubleprivate static final intprivate intprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddExponentToResult(int exponent) private voidaddToResult(byte b) private doubleprivate booleanvoidprivate static booleanisDigit(byte b) private booleanisEOS()private static booleanisExponent(byte b) private static booleanisWhitespace(byte b) private bytenext()doubleEverything runs in 1.9+ mode now, so the `is19` parameter is vestigial.private booleanprivate booleanprivate booleanprivate booleanprivate booleanprevious()Shift back to previous character in the incoming bytesprivate booleanConsume initial whitespace and underscores so that next character examined is not whitespace.private booleanprivate booleanprivate booleantooLargeExponent(boolean negativeFloat, boolean negativeExponent) private voidprivate void
-
Field Details
-
bytes
private byte[] bytes -
index
private int index -
endIndex
private int endIndex -
isStrict
private boolean isStrict -
chars
private char[] chars -
charsIndex
private int charsIndex -
significantDigitsProcessed
private int significantDigitsProcessed -
adjustExponent
private int adjustExponent -
wroteExponent
private boolean wroteExponent -
result
private double result -
SIGNIFICANT_DIGITS_LIMIT
private static final int SIGNIFICANT_DIGITS_LIMIT- See Also:
-
EXPONENT_DIGITS_LIMIT
private static final int EXPONENT_DIGITS_LIMIT- See Also:
-
MAX_EXPONENT
private static final int MAX_EXPONENT -
MAX_LENGTH
private static final int MAX_LENGTH- See Also:
-
-
Constructor Details
-
DoubleConverter
public DoubleConverter()
-
-
Method Details
-
init
-
next
private byte next() -
previous
private boolean previous()Shift back to previous character in the incoming bytes- Returns:
- false to indicate we are not in an EOS condition
-
isEOS
private boolean isEOS() -
stopParsing
private boolean stopParsing() -
isDigit
private static boolean isDigit(byte b) -
isExponent
private static boolean isExponent(byte b) -
isWhitespace
private static boolean isWhitespace(byte b) -
addToResult
private void addToResult(byte b) -
addExponentToResult
private void addExponentToResult(int exponent) -
eatUnderscores
private boolean eatUnderscores() -
completeCalculation
private double completeCalculation() -
strictError
private boolean strictError() -
parse
Everything runs in 1.9+ mode now, so the `is19` parameter is vestigial. However, in order to maintain binary compatibility with extensions we can't just change the signature either. -
skipWhitespace
private boolean skipWhitespace()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 -
parseOptionalSign
private boolean parseOptionalSign() -
parseDigits
private boolean parseDigits() -
parseDecimalDigits
private boolean parseDecimalDigits() -
parseExponent
private boolean parseExponent() -
tooLargeExponent
private boolean tooLargeExponent(boolean negativeFloat, boolean negativeExponent) -
verifyOnlyNumbers
private void verifyOnlyNumbers() -
verifyNumberAfterUnderscore
private void verifyNumberAfterUnderscore()
-