The ISNULL expression is always deterministic when called within a UDF and therefore will return a value of the same data type (int) as the input expression. That is why you have to check for the NULL value in your UDF.