$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Paul A Bristow (pbristow_at_[hidden])
Date: 2006-03-15 07:13:13
I have also re-tested this on VS 2005 release :-(((
My test and/or memory was obviously faulty.
Using 100 tests with nextafter, starting with the value you found faulty, I
find 38 failures (all one bit wrong on input) - about the one third I found
in previous tests.
So I confirm my view that this is a Microsoft 'Lack Of Quality Feature'.
To be fair, this is a rather hard problem, though there are proven solutions
which have been proposed, but not widely implemented, as I asked about and
got some info on a recent post.
listarchives.boost.org/Archives/boost/2006/02/date.php
But I fear that this does NOT help you just now. Sorry.
I am having a crack at using the Burger and Dvbvig method but have yet to
fully understand it.
Paul
--
Paul A Bristow
Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB
Phone and SMS text +44 1539 561830, Mobile and SMS text +44 7714 330204
mailto: pbristow_at_[hidden] http://www.hetp.u-net.com/index.html
http://www.hetp.u-net.com/Paul%20A%20Bristow%20info.html
| -----Original Message-----
| From: boost-bounces_at_[hidden]
| [mailto:boost-bounces_at_[hidden]] On Behalf Of Paul Giaccone
| Sent: 15 March 2006 11:06
| To: boost_at_[hidden]
| Subject: Re: [boost] [serialization]
| Serialisation/deserialisation offloating-point values
|
| Paul A Bristow wrote:
|
| >If you want to test round-tripping on your platform and std
| lib without
| >actually using serialization,
| >
| >may I suggest a loop including something like:
| >
| > double a = some start value;
| > double aa; // to hold the read back.
| >
| > std::stringstream s;
| > s.precision(2+std::numeric_limits<double>::digits * 3010/10000);
| > // cout << "output " << a;
| > s << a; // output to string s
| > //cout << ", s.str() is " << s.str();
| > s >> aa; // read back in.
| > //cout << ", read back " << aa << endl;
| > if (a != aa)
| > {
| > cout << "error " << a << tab << aa << endl;
| > }
| > a = nextafter(a, std::numeric_limits<double>::max());
| // Make one
| >bit bigger?
| >
| >
| >
| [...]
|
| >This should give you a feel for the risk of failure.
| >
| >Paul
| >
| >
| Funnily enough, I've just written a program to test the value I
| originally posted about (below, followed by its output):
|
| #include <string>
| #include <sstream>
| #include <iostream>
| #include <iomanip>
| #include <limits>
|
| int main(void)
| {
| const double orig_value = 0.0019075645054089487;
| std::stringstream stream;
|
| double num;
| stream << std::setprecision(2 +
| std::numeric_limits<double>::digits
| * 3030/10000);
| stream << orig_value;
| stream >> num;
|
| if (num == orig_value)
| {
| std::cout << "Match" << std::endl;
| }
| else
| {
| std::cout << "Deserialisation error" << std::endl;
| std::cout << std::setprecision(2 +
| std::numeric_limits<double>::digits * 3030/10000);
| std::cout << "Original numerical value: " << orig_value <<
| std::endl;
| std::cout << "Contents of stream: " << stream.str()
| << std::endl;
| std::cout << "Deserialised value: " << num << std::endl;
| }
|
| return 0;
| }
|
|
| Output:
|
| Deserialisation error
| Original numerical value: 0.0019075645054089487
| Contents of stream: 0.0019075645054089487
| Deserialised value: 0.0019075645054089489
|
|
| This is the same result as in my original thread, so it does
| indeed look
| like a Microsoft issue with redirection (>>), not with
| serialisation itself.
|
| Paul
|
|
| _______________________________________________
| Unsubscribe & other changes:
| http://listarchives.boost.org/mailman/listinfo.cgi/boost
|