IDEA-115034 (Good code red: hex float zero)

This commit is contained in:
Bas Leijdekkers
2013-10-17 13:43:52 +02:00
parent 52557fa9cd
commit 03e63d75d3
2 changed files with 8 additions and 2 deletions
@@ -1460,12 +1460,16 @@ public class TypeConversionUtil {
return null;
}
// true if floating point literal consists of zeros only
/**
* See JLS 3.10.2. Floating-Point Literals
* @return true if floating point literal consists of zeros only
*/
public static boolean isFPZero(@NotNull final String text) {
for (int i = 0; i < text.length(); i++) {
final char c = text.charAt(i);
if (Character.isDigit(c) && c != '0') return false;
if (Character.toUpperCase(c) == 'E') break;
final char d = Character.toUpperCase(c);
if (d == 'E' || d == 'P') break;
}
return true;
}
@@ -33,6 +33,7 @@ public class NumericLiterals {
float f10 = 0xa_bc.d_efP0F;
float f11= <error descr="Floating point number too small">1e-4__6f</error>;
float f12 = <error descr="Floating point number too large">1e3_9f</error>;
float f13 = 0x0.0p1f;
double d1 = 0_0d;
double d2 = 1e1_1;
@@ -48,5 +49,6 @@ public class NumericLiterals {
double d12 = <error descr="Floating point number too large">0xa_bc.de_fP1_234D</error>;
double d13 = <error descr="Illegal underscore">0x1.0_p-1</error>;
double d14 = <error descr="Illegal underscore">1.0e_1022</error>;
double d15 = 0x.0P2d;
}
}