The problem I'm facing with my code is the if statement doesn't work when I multiply a number with a float. Such as
int x;
float xRatio = 1.0;
if ( x > 600 * xRatio && x < 1320 * xRatio) {
// Do something (Draw on canvas for android)
}
However, even when I try this
float xCompare1 = 1320 * xRatio;
System.out.println(xCompare1);
It either prints 0 or NaN.
I don't understand why the if statement doesn't work, as it works when I use it in this
if (x > 100 * xRatio && x < 599 * xRatio) {
// Do something
}
it works and it's really confusing me
// EDIT
Well this is how I define my xRatio and my xValue
Point size = new Point();
this.getWindowManager().getDefaultDisplay.getRealSize(size);
double width = size.x;
float xRatio = (float) width/1920;
x+= 20;
canvas.drawBitmap(bitmap, x, 0, null);