As Wims explained, an IF looks to see if something is true or not. Not true includes the three things mentioned (0, $null, $false). If you need it to treat a 0 as true, then you need to be more specific in your IF....
For example:
*Note that the above example would also be true for $false, so depending on what %var could be, you may also need to include an OR to check if it's != $false as well.