avatar

Professional Nerd Herder: Dennis Skinner

Properly Casting Integers in C

I believe the most common mistake I see in both new and experienced users of C is incorrect or dangerous integer casting. It appears to me that these troubled developers are equating casting to conversion without realizing they’re introducing bugs into their software. I’m unsure if this is because of lack of knowledge, laziness, or forgetfulness due to working in higher-level languages, but whatever the reason I see it often (and I’m guilty of it too!