MCPcopy Create free account
hub / github.com/beanshell/beanshell / parseInt

Method parseInt

src/bsh/Parser.java:133–158  ·  view source on GitHub ↗
(String s)

Source from the content-addressed store, hash-verified

131 }
132
133 int parseInt(String s) throws NumberFormatException {
134 int radix;
135 int i;
136 if( s.startsWith("0x") || s.startsWith("0X") ) {
137 radix = 16;
138 i = 2;
139 } else if( s.startsWith("0") && s.length() > 1 ) {
140 radix = 8;
141 i = 1;
142 } else {
143 radix = 10;
144 i = 0;
145 }
146 int result = 0;
147 int len = s.length();
148 for( ; i<len; i++ ) {
149 if( result < 0 )
150 throw new NumberFormatException("Number too big for integer type: "+s);
151 result *= radix;
152 int digit = Character.digit(s.charAt(i),radix);
153 if( digit < 0 )
154 throw new NumberFormatException("Invalid integer type: "+s);
155 result += digit;
156 }
157 return result;
158 }
159
160 long parseLong(String s) throws NumberFormatException {
161 int radix;

Callers 7

LiteralMethod · 0.95
charSetupMethod · 0.80
stringSetupMethod · 0.80
getErrorLineNumberMethod · 0.80
evalMethod · 0.80
doBshMethod · 0.80
mainMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected