CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
using namespace std;
int main() {
double a = 0.1, b = 0.2 , c = 0.3 ;
if (a + b == c)
cout << " eq " << endl ;
else
cout << " not " << endl ;
/*
prints not
Because double has 15 decimal digits of
precision means:
a=0.1 0.100000000000001
b=0.2 0.200000000000003
c=0.3 0.300000000000004 */
float x = 0.1, y = 0.2 , z = 0.3 ;
if (x + y == z)
cout << " eq " << endl ;
else
cout << " not " << endl ;
/*
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run