Internet
Fact-checked

At WiseGEEK, we're committed to delivering accurate, trustworthy information. Our expert-authored content is rigorously fact-checked and sourced from credible authorities. Discover how we uphold the highest standards in providing you with reliable knowledge.

Learn more...

What Is Bounds Checking?

Mary McMahon
Mary McMahon
Mary McMahon
Mary McMahon

Bounds checking is a procedure to make sure a variable conforms with the bounds of an array. In programming, variables that fall outside the bounds can create problems with the operation of a program and may freeze it or cause an error. For some types of programming languages, this procedure is standard to protect the integrity of operations and arrays, while in others it may need to be actively performed on an order from the operator.

In a simple example of bounds checking, if a programmer has an array ranging between two and 14 and tries to insert 16 as a variable, it does not fit. It would be out of bounds, and depending on what the array is used for, might create a serious error. For example, if the array represents available memory, an out of bounds variable would result in an illegal operation; the array doesn't allow it, and the system might create an error with the stored data or be unable to store it at all.

Woman doing a handstand with a computer
Woman doing a handstand with a computer

In bounds checking, it is possible to determine if a variable falls within an allowable range, or to evaluate an index to see if it fits within the stated bounds. If there is a problem, the program can flag it, allowing the programmer to fix it before attempting an operation that will fail. This can prevent the development of bad references and other issues that may arise when the bounds of an array are ignored. Computer errors related to violations of the bounds can be challenging to fix, and techniques to avoid them will make a program run more smoothly.

Handling of bounds checking in various programming languages varies. As people learn programming, they learn more about the full features and functions available and decide how best to use them, given the type of work they do. Numerous products can perform bounds checking if it is not native to a programming language. Some of these are available for free, and may not work with all systems or languages, but can provide a good start.

A failure to perform bounds checking can have consequences in the future, although the programmer may not notice the problem immediately. Debugging processes may include bounds checking to look for obvious issues. Multiple passes of debugging are typically part of the development process, to catch as many problems as possible before software is released to the general public. A poorly prepared product may be prone to error and could generate consumer frustration.

Mary McMahon
Mary McMahon

Ever since she began contributing to the site several years ago, Mary has embraced the exciting challenge of being a WiseGEEK researcher and writer. Mary has a liberal arts degree from Goddard College and spends her free time reading, cooking, and exploring the great outdoors.

Learn more...
Mary McMahon
Mary McMahon

Ever since she began contributing to the site several years ago, Mary has embraced the exciting challenge of being a WiseGEEK researcher and writer. Mary has a liberal arts degree from Goddard College and spends her free time reading, cooking, and exploring the great outdoors.

Learn more...

Discuss this Article

Post your comments
Login:
Forgot password?
Register:
    • Woman doing a handstand with a computer
      Woman doing a handstand with a computer