Can't work with screen.width / height

This is my code:

function OnGUI () {

var H = Screen.height;
var W = Screen.width;
var Ratio;

Ratio = H / W;

GUI.Label (Rect (10, 110, 100, 20), "Screen.width "+ W.ToString());
GUI.Label (Rect (10, 130, 120, 20), "Screen.height "+ H.ToString());
GUI.Label (Rect (10, 150, 120, 20), "Screen ratio "+ Ratio.ToString());
}

When i run it, it displays proper screen dimensions, but Ratio is always 0. Also when i try to operate on Screen.height or Screen.width (add to them etc.) they become zeros. I followed tutorials and copy/pasted code from documentation - the Screen.width and .height show ok only if i don’t try to use them in calculations. This is becoming frustrating, what am i missing here?

This happens both in editor and in build.

Integer division always gives an integer result. If you want float division, at least one of the numbers involved must be a float.

This happens because ‘Screen.height’ and ‘Screen.width’ return integers! Therefore, the division operator will return 0 in all cases in which the second number is larger than the first. Try this simple modification to your code (and lament the fact that UnityScript even allows you to make mistakes of this kind- if it was statically typed you’d have picked this one up immediately…)

var H : float = Screen.height;
var W : float = Screen.width;

var Ratio : float = H / W;

Just try…
var W : float = Screen.width * 1.0;
I tried it and the issue was gone.