Linked Questions

4 votes
4 answers
3k views

I have two integer vectors of nearly 1000 size, and what I am going to do is to check whether the sum of the square integer for these two vectors is the same or not. So I write the following codes: ...
feelfree's user avatar
  • 11.9k
8 votes
1 answer
10k views

if (std::abs(double1 - double2) < std::numeric_limits<double>::epsilon()) std::cout<<"Equal"; else std::cout<<"Not equal"; Is this code with modern C++11/...
Bruice's user avatar
  • 713
0 votes
8 answers
341 views

Possible Duplicate: Most effective way for float and double comparison strange output in comparison of float with float literal int main() { float a = 0.8; if (a == 0.8) printf("x\n"); ...
user1593308's user avatar
0 votes
5 answers
4k views

Possible Duplicate: Most effective way for float and double comparison In my program some double variables take values of the form 1.00000001. Equality check of these variables with 1 obviously ...
stressed_geek's user avatar
5 votes
5 answers
550 views

When comparing two "real" numbers for equality, why should I not use the == operator, and what should I use instead? What is the difference between coersion and casting? It is my general assumption ...
0 votes
4 answers
2k views

Possible Duplicate: Most effective way for float and double comparison I have two values(floats) I am attempting to add together and average. The issue I have is that occasionally these values ...
Evan's user avatar
  • 279
0 votes
3 answers
784 views

Possible Duplicate: Most effective way for float and double comparison I am new to C++. I had a doubt, while reading C++. How to decide two floating point numbers equal to each other or not ? ...
Jholar99's user avatar
3 votes
2 answers
2k views

I read that floats/doubles equality should be implemented using an interval (given by some epsilon): bool aresame(double a, double b) { return (fabs(a-b) < EPSILON); } Is their any predefined ...
John Lui's user avatar
  • 1,484
-1 votes
3 answers
394 views

Is there built-in library can compare float or double I do not think compare like a == b or a !=b makes any sense. Any suggestion?
Adam Lee's user avatar
  • 26k
0 votes
2 answers
1k views

So I've understood for a long time that floating point equality is not perfect in any programing language. But until recently after uncovering a bug at work related to this issue, I never realized ...
nmg49's user avatar
  • 1,406
1 vote
2 answers
833 views

Possible Duplicate: Most effective way for float and double comparison How dangerous is it to compare floating point values? I have const float M = 0.000001; and float input;. I want to not ...
user1802858's user avatar
-4 votes
5 answers
784 views

Please before you think that I'm asking the same N% Question read it first and please pay Attention to it. I'm working on a project where I have more functions which returns double and it may be ...
Michi's user avatar
  • 5,327
-5 votes
6 answers
394 views

I've seen posts like: What is the most effective way for float and double comparison? Compare two floats And many other related posts. I saw in d3js library, it uses the following comparison: ...
gongzhitaao's user avatar
  • 6,732
0 votes
1 answer
913 views

I'm writing a function which accepts a double data type, say variable 't', and if 't' is equal to 0.05, the function does something. Now, my problem is that if 't' is 100-99.5, the function fails to ...
user3073511's user avatar
-2 votes
1 answer
149 views

This post stated that you shouldn't compare floating point variables with == because of rounding errors. What should I use then, and when?

15 30 50 per page
1
2 3 4 5
...
15