DEV Community

Discussion on: Industries Where Your C Code Saves Lives (And They're Hiring)

Collapse
 
pauljlucas profile image
Paul J. Lucas

In C, when you multiply two integers and the result exceeds the maximum value the integer type can hold, you don't get an error. You get wraparound.

In fairness, most programming languages do the same thing unless you use special arithmetic methods (if available).

Collapse
 
fosres profile image
fosres • Edited

Hi! Thanks for your comment. It's true. I was just pointing out that C was so heavily used in industries dealing with life-or-death situations that it's a problem when using the language.

Collapse
 
pauljlucas profile image
Paul J. Lucas

Yes, but your statement makes it sound like it's C's fault in particular.

Thread Thread
 
fosres profile image
fosres

Hm. Okay. How would you like me to change it?

Thread Thread
 
pauljlucas profile image
Paul J. Lucas

There are many ways to rewrite it, such as:

In virtually all programming languages, C included, when you multiply two integers ...

Thread Thread
 
fosres profile image
fosres

Great. Done.