diff --git a/examples/example1.cpp b/examples/example1.cpp index 35f9ba1..0c6cd5f 100644 --- a/examples/example1.cpp +++ b/examples/example1.cpp @@ -15,10 +15,7 @@ int main(int argc, const char * argv[]){ int z; // this produces an invalid result ! z = x + y; - // but assert fails to detect it since C++ implicitly - // converts variables to int before evaluating he expression! - // assert(z == x + y); - std::cout << static_cast(z) << " != " << x + y << std::endl; + std::cout << z << " != " << x + y << std::endl; std::cout << "error NOT detected!" << std::endl; } catch(std::exception){ @@ -28,14 +25,14 @@ int main(int argc, const char * argv[]){ std::cout << "Using safe numerics" << std::endl; try{ using namespace boost::numeric; - safe x = 127; + safe x = INT_MAX; safe y = 2; safe z; - // rather than producing and invalid result an exception is thrown + // rather than producing an invalid result an exception is thrown z = x + y; } catch(std::exception & e){ - // which can catch here + // which we can catch here std::cout << e.what() << std::endl; } return 0;