blob: a625c87f7062ad1ed8a81050c6666918101ba52d [file] [log] [blame]
package com.siyeh.igtest.numeric.unnecessary_explicit_numeric_cast;
public class UnnecessaryExplicitNumericCast {
void a(byte b) {
double d = (double) 1;
d = (double) 1.0f;
d = (double) b;
char c = (char) 1;
b = (int)7;
}
double b(int a, byte b) {
return (double)a * (double) b;
}
public static void main(String[] args) {
int i = 10;
double d = 123.0 / (456.0 * (double) i);
}
void unary() {
byte b = 2;
int a[] = new int[(int)b];
final int c = a[((int) b)];
int[] a2 = new int[]{(int)b};
int[] a3 = {(int)b};
final int result = (int) b << 1;
c((int)b);
new UnnecessaryExplicitNumericCast((long)b);
}
void c(int i) {}
UnnecessaryExplicitNumericCast(long i) {}
void c(int cols, int no) {
int rows = (int) Math.ceil((double) no / cols);
}
void source() {
target((int)'a');
target2((int)'b');
}
void target(int c) {}
void target(char c) {}
void target2(int d) {}
void foo() {
float x = 2;
target((int) x); // this line complains: 'x' unnecessarily cast to 'int'
}
void a(float angleFromTo) {
float f = (float) Math.cos(0.5) * 1.0f; // necessary
final long l = (long) i() * 9L;
float angle2 = angleFromTo + (float) (Math.PI / 2);
}
int i() {
return 10;
}
boolean redundantTypeCast(long l) {
return 0L == (long)l;
}
}