0
double f1 = 0.00000001;
double f2 =  7.00000001;
double f3 = -7.00000000;
double sum = f2 + f3;
bool shouldBeTrue = sum == f1;

shouldBeTrue is false using VS C++ 2015/2017

float f1 = 0.00001;
float f2 = 7.00001;
float f3 = -7.00000;
float sum = f2 + f3;
bool shouldBeTrue = sum == f1;

shouldBeTrue is false using VS C++ 2015/2017

how to implement this in c++ so I can store the values written in the code and not the approximations? any new types or library available? (e.g. like decimal type in c#)

ovi
  • 460
  • 4
  • 18

0 Answers0