Last active
November 2, 2017 21:58
-
-
Save amorphid/37e935f679afcf6addeebbdd13822276 to your computer and use it in GitHub Desktop.
C++ addition precision
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iomanip> | |
using namespace std; | |
int main () { | |
double a = 0.1; | |
double b = 0.2; | |
double result = a + b; | |
// prints 0.30000000000000004441 | |
cout << setprecision(20) << result << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment