
Le 10/12/2015 08:49, Robert Ramey a écrit :
Arithmetic operations in C++ are NOT guaranteed to yield a correct mathematical result. This feature is inherited from the early days of C. The behavior of int, unsigned int and others were designed to map closely to the underlying hardware. Computer hardware implements these types as a fixed number of bits. When the result of arithmetic operations exceeds this number of bits, the result will not be arithmetically correct.
I have crafted a library to address this issue once and for all. You can find out more about this by checking out the page for Safe Numerics at the boost library incubator. www.blincubator.com
I hereby request that this library be added to the boost review queue.
I've also made a proposal for the C++ Standards committee to include a simplified version of this library as part of he C++ standard.
You can see the proposal at http://www.rrsd.com/software_development/safe_numerics/proposal.pdf
Hi Robert, these links are broken Library Implementation <https://htmlpreview.github.io/?https://raw.githubusercontent.com/robertramey/safe_numerics/master/doc/html/index.html> Checked_Result<R> <https://htmlpreview.github.io/?https://raw.githubusercontent.com/robertramey/safe_numerics/master/doc/html/index.html> Checked Integer Arithmetic <https://htmlpreview.github.io/?https://raw.githubusercontent.com/robertramey/safe_numerics/master/doc/html/index.html> Interval Arithmetic <https://htmlpreview.github.io/?https://raw.githubusercontent.com/robertramey/safe_numerics/master/doc/html/index.html> Performance Tests <https://htmlpreview.github.io/?https://raw.githubusercontent.com/robertramey/safe_numerics/master/doc/html/index.html> minor comments: * I believe the name safe<T> is too broad for the kind of types this class can wrap. * Remove any adherence to boost in the standard proposal (include <boost/...) * I see that boost::numeric::safe and std::safe differ on the template parameters. I see why the standard version is not configurable and just throws. However, I don't see why this doesn't applies to the proposal for Boost. What is not good for the standard can be good for Boost? Vicente