Re: [Boost-users] incorrect random library equality implementation?

Scott McMurray wrote:
What the random streaming operators are doing is saving and restoring the state of the lagged_fibonacci607 object with text. This involves converting the doubles into strings and back again. I'm not certain if ISO C++ specifies whether we are allowed to assume the conversion from double to string and back always yields the identical floating point number or not. Here is a small test program that demonstrates what the random test suite is essentially doing: #include <iostream> #include <sstream> int main() { double pi = 3.14159; double pi2 = pi; if ( pi != pi2 ) { std::cout << "test failed, pi != pi2\n"; return -1; } std::ostringstream file; file << pi; std::string ostr(file.str()); std::istringstream input(file.str()); input >> pi; std::string istr(input.str()); if ( pi != pi2 ) { std::cout << "test failed, restored pi != pi2\n"; } else { std::cout << "passed\n"; } } This test always fails here. --Steven
participants (1)
-
Steven Solie