// (1) When parsing the format, remove the sign from after the 'e' and\r
// put it before the first digit of the exponent.\r
if (exponent == null && specials.size() > 0) {\r
- specials.add(exponent = new Special('.', pos));\r
+ exponent = new Special('.', pos);\r
+ specials.add(exponent);\r
insertSignForExponent = part.charAt(1);\r
return part.substring(0, 1);\r
}\r
break;\r
\r
case '.':\r
- if (decimalPoint == null && specials.size() > 0)\r
- specials.add(decimalPoint = new Special('.', pos));\r
+ if (decimalPoint == null && specials.size() > 0) {\r
+ decimalPoint = new Special('.', pos);\r
+ specials.add(decimalPoint);\r
+ }\r
break;\r
\r
case '/':\r
numerator = previousNumber();\r
// If the first number in the whole format is the numerator, the\r
// entire number should be printed as an improper fraction\r
- if (numerator == firstDigit(specials))\r
- improperFraction = true;\r
- specials.add(slash = new Special('.', pos));\r
+ improperFraction |= (numerator == firstDigit(specials));\r
+ slash = new Special('.', pos);\r
+ specials.add(slash);\r
}\r
break;\r
\r
return part;\r
}\r
\r
- public char getInsertSignForExponent() {\r
- return insertSignForExponent;\r
- }\r
-\r
public double getScale() {\r
return scale;\r
}\r
while (it.hasPrevious()) {\r
Special s = it.previous();\r
if (isDigitFmt(s)) {\r
- Special numStart = s;\r
Special last = s;\r
while (it.hasPrevious()) {\r
s = it.previous();\r
- if (last.pos - s.pos > 1) // it has to be continuous digits\r
- break;\r
- if (isDigitFmt(s))\r
- numStart = s;\r
- else\r
+ // it has to be continuous digits\r
+ if (last.pos - s.pos > 1 || !isDigitFmt(s)) {\r
break;\r
+ }\r
last = s;\r
}\r
- return numStart;\r
+ return last;\r
}\r
}\r
return null;\r
\r
private static Special firstDigit(List<Special> specials) {\r
for (Special s : specials) {\r
- if (isDigitFmt(s))\r
+ if (isDigitFmt(s)) {\r
return s;\r
+ }\r
}\r
return null;\r
}\r