java - Multiply my a number with a float? -


the problem i'm facing code if statement doesn't work when multiply number float. such

int x; float xratio = 1.0; if ( x > 600 * xratio && x < 1320 * xratio) {                            // (draw on canvas android) } 

however, when try this

float xcompare1 = 1320 * xratio; system.out.println(xcompare1); 

it either prints 0 or nan.

i don't understand why if statement doesn't work, works when use in this

    if (x > 100 * xratio && x < 599 * xratio) {         //     } 

it works , it's confusing me

// edit

well how define xratio , 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); 

i tried working, need change float xratio = 1.0; float xratio = 1.0f;


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -