Maybe a silly question, but today I've faced this type-generic code:
float f_u( unsigned T v )
{
if ( v == 0u )
{
return 0.0f;
}
...
return result;
}
Is unsigned-suffix u really needed in this case?
In other words: what can possibly go wrong without using u?
UPD.
- The question is about
C, notC++. Updated code sample. - Answer to https://xyproblem.info: the
actual problemis: there are another functionf_s()forsigned T v, which usesif ( v == u ). Now I'm thinking of mergingf_u()withf_s()into commonf_x(). Theactual problem: inf_x()do I need to keep thisuor it can be safely omitted?