I had this code as part of a C ++ project
unsigned int fn() {
int value = ....
if(value <= 0)
return 0;
return (unsigned int)value;
}
I do not need to use the cast in the last return expression, since all negative numbers will be caught in the if statement (from where 0 is returned).
And besides, this function fnis called from another function (whose return type int), which simply returns the value returned fn.
Thanks..
source
share