David LeBlanc introduces a C++ template class that helps reduce the chances of incurring integer arithmetic errors in your code. The code is fast, flexible, and easy to use. Get a handle on optimizing floating-point code using the Microsoft Visual C++ (v8.0) method of managing floating-point semantics. Create fast programs while ensuring that only safe optimizations are performed on floating-point code.
I don’t understand, why would integer overflow be a real problem? Maybe they’re using the wrong datatype. Any excuse to make things slower…
This is like saying why are buffer overflows a problem? It’s really a trivial problem to not have isn’t it.
If you’re a careful, reasonable, and good programmer, none of these should be a problem. Yep, maybe they’re simply using a datatype too small. Just like some buffers are declared too small.
You could be doing a counter of some kind and don’t think it will ever exceed 32bits. The “y2k” bug is a kind of overflow problem. They used a datatype too small. You might be keeping count of a list of items…
Or let’s take someone making a very simply integer calculator program. LIke a ‘good’ programmer, they declare all variables as int. Someone decides to add 2 huge numbers together. They don’t check for overflow –problem.
This is a nice little template. This kind of safety classes are always nice to have around if not just for debugging purposes or for applications which are not arithmetically intensive.
OSNews, now featuring C++ library ads! OSNews, where you can find everything related to OSes, or even tangentially related, or not related at all!
How did David get this on here? Is he Eugenia’s boyfriend, or something?
Because this would enable programmers to write safer code, and in the long run could make OSes more stable and secure?