Use of constant in Canvas.drawLine()
<p>I have this code.
Only the first drawLine gets drawn and the rest 2 are not. Can anyone explain why the other two drawlines do not work in the present case?
They work if I replace "factor" with "1/2" in the drawLine() statements.
Thanks</p>

<p>public class RenderView extends View {</p>

<pre><code>Paint paint;
private float factor = 1/2;

public RenderView(Context context) {
    // TODO Auto-generated constructor stub
    super(context);
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
}

@Override
protected void onDraw(Canvas canvas) {

    int screenWidth = canvas.getWidth();
    int screenHeight = canvas.getHeight();

    paint.setColor(Color.RED);


    canvas.drawLine(0, 0, screenWidth, screenHeight, paint);

    canvas.drawLine(factor*screenWidth, 0, factor*screenWidth, screenHeight, paint);


    canvas.drawLine(0, factor*screenHeight, screenWidth, factor*screenHeight, paint);

    invalidate();       
}
</code></pre>

<p>}</p>
