SQL does a lot of implicit data type conversions when it is processing queries. This occurs whenever the data types are not exactly the same (e.g. assigning an INT to a BIGINT).
When the conversion is between a character datatype and and int data type, and the char column or variable is either space or empty string, it is converted to 0.