Re: Surprising Behavior Comparing Floats

2014-01-11 Thread Nick
On Sat, 2014-01-11 at 15:24 +, Rob wrote: > On Sat, 11 Jan 2014, Nick wrote: > > I'm very surprised by the result in #6. #7 seems to be doing the same > > thing, except that it uses a local variable to hold the sum. > > Sounds to me like it could be related to excess precision - checkout the

Re: Surprising Behavior Comparing Floats

2014-01-11 Thread Nick
On Sat, 2014-01-11 at 16:24 +0100, Marc Glisse wrote: > First, this is not an appropriate list for this question. gcc-help would > be better. Sorry about that--my e-mail auto completed the address and I wasn't paying enough attention. > Second, there are hundreds of places on the internet answer

Re: Surprising Behavior Comparing Floats

2014-01-11 Thread Rob
On Sat, 11 Jan 2014, Nick wrote: I'm very surprised by the result in #6. #7 seems to be doing the same thing, except that it uses a local variable to hold the sum. Sounds to me like it could be related to excess precision - checkout the -ffloat-store option. I don't see it on my machine either

Re: Surprising Behavior Comparing Floats

2014-01-11 Thread Marc Glisse
On Sat, 11 Jan 2014, Nick wrote: First, I know that floating point variables should not be compared "raw" due to the way they're represented. But the behavior I'm seeing has me surprised. First, this is not an appropriate list for this question. gcc-help would be better. Second, there are hu

Surprising Behavior Comparing Floats

2014-01-11 Thread Nick
First, I know that floating point variables should not be compared "raw" due to the way they're represented. But the behavior I'm seeing has me surprised. Here's a small repo example: --- #include using namespace std; int main() { float f1(4.94f + 0.2f