This is because of the implicit typecast that is executed internally by the compiler.
When an operation occurs between two different types of variables, the compiler itself (temporarily converts) the lower data type to the higher data type.
Here in your code, -1 temporarily acts like an unsigned long , because implicit typecasting is done by the compiler itself. It behaves like an unsigned long , because the other variable is pf.
here -1 is not considered as -1 , but it is treated as its equivalent as an unsigned long .
source share