[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #40560] a < b incorrect for complex numbers on
From: |
Michael Goffioul |
Subject: |
[Octave-bug-tracker] [bug #40560] a < b incorrect for complex numbers on MinGW |
Date: |
Wed, 13 Nov 2013 18:06:16 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.114 Safari/537.36 |
Follow-up Comment #1, bug #40560 (project octave):
I believe this is due to rounding/truncation error accumulation in the FPU
registers. Consider the following test code (adapt the octave include to the
actual location of octave source tree):
#include <complex>
#include <iostream>
#define FLOAT_TRUNCATE
#include "octave-hg/liboctave/util/oct-cmplx.h"
int main (int argc, char **argv)
{
std::complex<double> c1;
std::complex<double> c2;
c1 = std::complex<double> (0, 1);
c2 = std::complex<double> (0, 1);
bool r1 = (c1 < c2);
bool r2 = (c1 == c2);
bool r3 = (c1 > c2);
std::cout << "result:" << std::endl;
std::cout << " < : " << r1 << std::endl;
std::cout << " = : " << r2 << std::endl;
std::cout << " > : " << r3 << std::endl;
return 0;
}
The expected output is r1=0, r2=1, r3=0. However it occurs that the output can
be r1=1, r2=1, r3=0
Using MinGW/GCC-4.8.1 I can observe the following:
- compiling with -O2 leads to incorrect output
- compiling with -O0 leads to correct output
- compiling with -O2 and defining FLOAT_TRUNCATE to "volatile" leads to
correct output
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?40560>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #40560] a < b incorrect for complex numbers on MinGW, Rik, 2013/11/12
- [Octave-bug-tracker] [bug #40560] a < b incorrect for complex numbers on MinGW, Rik, 2013/11/13
- [Octave-bug-tracker] [bug #40560] a < b incorrect for complex numbers on MinGW,
Michael Goffioul <=
- [Octave-bug-tracker] [bug #40560] a < b incorrect for complex numbers on MinGW, Rik, 2013/11/13
- [Octave-bug-tracker] [bug #40560] a < b incorrect for complex numbers on MinGW, Rik, 2013/11/13
- [Octave-bug-tracker] [bug #40560] a < b incorrect for complex numbers on MinGW, Michael Godfrey, 2013/11/13
- [Octave-bug-tracker] [bug #40560] a < b incorrect for complex numbers on MinGW, Rik, 2013/11/13
- [Octave-bug-tracker] [bug #40560] a < b incorrect for complex numbers on MinGW, Rik, 2013/11/13