9 April 2021 by Phillip Johnston • Last updated 14 December 2021 This entry was contributed Nathan Jones. Thanks Nathan! Integer underflows and overflows are a common computational error that occurs in computer systems. These error conditions are often not explicitly checked for by developers. Ignoring the possibility of overflows or underflows can have disastrous results. Basic Overview Integer overflow occurs when the result of a math operation is too large to fit into the result variable’s data type. For example, the code below overflows if a = INT_MAX and b = 1. int add( int a, int b) { …
Continue reading “Integer Underflow and Overflow”
The Boost Safe Numerics library, created by Robert Ramey aims to enforce correct mathematical operations with the C++ language. Why are safer numeric operations needed? C++ inherited the behavior of the integral types (int, unsigned, long, etc.) from the C language, where they were designed to map closely to the underlying processor hardware. The types …
Continue reading "Enforce Correct Integer Arithmetic using the C++ Safe Numerics Library"
Apple's Open Source project is a great resource for finding source code to use in your own projects. I've found many useful libraries and functions by browsing Apple's open source code - and I know they've been pretty-well vetted since they are deployed on OS X and iOS. All around, Apple Open Source is a …
Continue reading "Apple’s Open Source libm"