(String name, boolean isDouble)
| 209 | |
| 210 | // Parses "+Nan", "NaN", "-Nan", "+Infinity", "Infinity", and "-Infinity", case-insensitively. |
| 211 | private static float parseName(String name, boolean isDouble) { |
| 212 | // Explicit sign? |
| 213 | boolean negative = false; |
| 214 | int i = 0; |
| 215 | int length = name.length(); |
| 216 | char firstChar = name.charAt(i); |
| 217 | if (firstChar == '-') { |
| 218 | negative = true; |
| 219 | ++i; |
| 220 | --length; |
| 221 | } else if (firstChar == '+') { |
| 222 | ++i; |
| 223 | --length; |
| 224 | } |
| 225 | |
| 226 | if (length == 8 && name.regionMatches(false, i, "Infinity", 0, 8)) { |
| 227 | return negative ? Float.NEGATIVE_INFINITY : Float.POSITIVE_INFINITY; |
| 228 | } |
| 229 | if (length == 3 && name.regionMatches(false, i, "NaN", 0, 3)) { |
| 230 | return Float.NaN; |
| 231 | } |
| 232 | throw invalidReal(name, isDouble); |
| 233 | } |
| 234 | |
| 235 | /** |
| 236 | * Returns the closest double value to the real number in the string. |
no test coverage detected