O'Reilly logo

C Programming: Visual Quickstart Guide by Marc Liyanage, Larry Ullman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Understanding Overflow and Underflow

Another source of potential conflict can arise when the value of a variable becomes too large or too small for its type for the computer running the application. When this occurs, it's called overflow and underflow. Depending on the computer, this will either cause an error or return alternative results.

This happens most frequently with floats, and it will obviously mess up any calculations made with such a value. When you attempt to print this variable, you'll most likely see either inf or infinity, indicating that the value is out of range.

The best way to avoid these problems is by knowing the limits for a particular type. This information is stored in the limits.h (for integers and characters) and float.h ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required