At -1l > 1ul -1l progresses to unsigned long , and by definition and standard -1, casting to unsigned will be the large value represented by this unsigned type.
I got my inspiration from the memory of this answer here to a rather topical question.
And after looking at the C99 project, I linger, see, for example, 6.3.1.3 (2), which says that the maximum value represented by the type will be added or subtracted from the original value until it enters the new type. I must warn you that char , although it is an integer type, is handled in a special way: it is determined by the implementation if char signed or unsigned. But this, strictly speaking, is next to the question.
source share