|
Boost Users : |
From: Leon Raj (Leon.Raj_at_[hidden])
Date: 2004-07-27 23:21:23
I think I've found a bug in the boost::lexical_cast<>
library (v1.31.0) on WinXP SP1, MSVC 6.0 (sp5) and
MSVC.NET 2003.
--- Start code snippet ---
#include <boost/lexical_cast.hpp>
#include <iostream>
int main( int argc, char* argv[] )
{
double dMax = = std::numeric_limits< double >::max();
// On a Win32 x86 system, dMax is now 1.7976931348623157e+308
// This is successful and strMax is "1.797693134862316e+308"
std::string strMax = boost::lexical_cast< std::string >( dMax );
try
{
double newDMax = boost::lexical_cast< double >( strMax );
std::cout << "Successfuly" << std::endl;
}
catch ( boost::bad_lexical_cast& )
{
std::cout << "Failed to cast" << std::endl;
}
// On a Win32 x86 system, this always fails,
// because (I think) strMax overflows a double,
// because 1.7976931348623157e+308 is *rounded UP*
// to 1.797693134862316e+308, which cannot be
// represented by a double
}
--- End code snippet ---
-----------------------------------------------------
Leon Raj
Senior Engineer
Invetech Pty. Ltd.
Phone: +61 3 9211 7000 (Switchboard)
+61 3 9211 7938 (DDI)
leon.raj_at_[hidden]
IMPORTANT - This e-mail and any attachments may be
confidential. Any retransmissions, dissemination or
other use of these materials by persons or entities
other than the intended recipient is prohibited.
If received in error, please contact us and delete
all copies. Before opening or using attachments,
check them for viruses and defects. Our liability
is limited to resupplying any affected attachments.
[Any representations or opinions expressed in this
e-mail are those of the individual sender, and not
necessarily those of Vision Systems Limited].
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net