I have very strange behavior with C ++ code. This gives me different results at startup and without redirecting the screen output to a file (playable in cygwin and linux). I mean, if I get the same executable and run it like ./runor run it like ./run >out.log, I get different results!
I use std :: cout for output to the screen, all lines ending with endl; I use ifstream for the input file; I use a stream for output, all lines end with endl.
I am using g ++ 4.
Any idea what is going on?
UPDATE: I hard-coded the input, so "ifstream" is not used, and the problem persists.
UPDATE 2: This is getting interesting. I checked the three variables that are computed initially, and what I get when using with and without redirecting the output to a file
redirected to file: 0 -0.02 0
direct to screen: 0 -0.02 1.04083e-17
Thus, there is a rounding difference in code variables with and without redirection of output!
Now, why will redirection interfere with internal code computation?
UPDATE 3: If I redirect to / dev / null, I get the sam behavior as output directly to the screen, rather than redirecting to a file.
source
share