What is the point of having a seperate unsigned type, aka NSUInteger
if there is no guarantee (nor even, it seems, a chance) that you can assume, bet your bottom dollar on, or cry yourself to sleep for - what the name implies - an inherently nonnegative result.
NSUInteger normal = 5;
NSUInteger freaky = normal - 55;
NSLog(@"%ld, %ld", normal, freaky);
NSLOG 5, -50
Sure, I can bend over backwards trying to get zero, or some kind of normalized value…
NSUInteger nonNeg = (((normal - 55) >= 0) ? (normal - 55) : 0);
PARRALELUNIVERSELOG 5, -50
But here the compiler complains.. rightfully so that comparison of unsigned expression >= 0 is always true
- and there it is, an answer I didn't want / expect. Someone slap my face, get me a drink, an tell me what year it is.. or better yet… how to make it - you know - not do that.
%lu
the results fornonNeg = 18446744073709551566
. but hey, at least it's positive, right… lol. – Chokebore