/**************************************************************** **** **** This file belongs with the course **** Introduction to Scientific Programming in C++/Fortran2003 **** copyright 2017 Victor Eijkhout eijkhout@tacc.utexas.edu **** **** intprec.cxx : test precision of int types **** ****************************************************************/ #include using std::abs; #include using std::cin, std::cout; #include using std::boolalpha; #include using std::vector; #include "printbits.cpp" #include int main() { float pointone; cin >> pointone; vector roundings = {FE_TONEAREST, FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO}; for ( auto round : roundings ) { fesetround(round); float sum = pointone+0.2f, three = 0.3f; cout << boolalpha << (sum==three) << '\n'; cout << sum-three << '\n'; } return 0; }