Files
Victor Eijkhout b13edff125 initial upload
2022-11-13 14:03:01 -06:00

32 lines
770 B
C++

/****************************************************************
****
**** This file belongs with the course
**** Introduction to Scientific Programming in C++/Fortran2003
**** copyright 2019-2020 Victor Eijkhout eijkhout@tacc.utexas.edu
****
**** point3.cxx : about truncation to float
****
****************************************************************/
#include <iostream>
using std::cin, std::cout;
int main() {
//codesnippet truncvsf
double point3d = .3/.7;
float
point3f = .3f/.7f,
point3t = point3d;
cout << "double precision: "
<< point3d << '\n'
<< "single precision: "
<< point3f << '\n'
<< "difference with truncation:"
<< point3t - point3f
<< '\n';
//codesnippet end
return 0;
}