What is the point of having a separate unsigned type, aka NSUInteger , if there is no guarantee (and it even seems likely) that you can put your lower dollar on, or cry yourself to sleep, as the name implies, is inherently non-negative result.
NSUInteger normal = 5; NSUInteger freaky = normal - 55; NSLog(@"%ld, %ld", normal, freaky);
NSLOG 5, -50
Of course, I can lean back trying to get zero or some normalized value ...
NSUInteger nonNeg = (((normal - 55) >= 0) ? (normal - 55) : 0);
PARRALELUNIVERSELOG 5, -50
But here the compiler complains .. by right, that the comparison of unsigned expression >= 0 is always true - and here it is, an answer that I did not want / expected. Someone pats my face, drinks, tells me what year it is ... or better ... how to do it - you know - donβt do it.
source share