Skip to content

Instantly share code, notes, and snippets.

@amorphid
Last active November 2, 2017 21:58
Show Gist options
  • Save amorphid/37e935f679afcf6addeebbdd13822276 to your computer and use it in GitHub Desktop.
Save amorphid/37e935f679afcf6addeebbdd13822276 to your computer and use it in GitHub Desktop.
C++ addition precision
#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