Board index » cppbuilder » First exception puzzles FPU (_control87)?

First exception puzzles FPU (_control87)?


2006-03-09 08:27:01 AM
cppbuilder112
Hi @all,
I am using BCB 6.0 and I have a problem using _control87(...). After an
exception (no matter which one) conversion between string and double
are handled totally wrong.
Please try the following piece of code:
---------------
#include <iostream>
#include <iomanip>
#include <sstream>
#include <float.h>
void test()
{
{
std::stringstream stream;
std::string str;
double d(1.0);
stream << std::setprecision(16);
stream << d << '\n';
stream>>str;
ShowMessage(str.c_str());
}
_control87(MCW_EM,MCW_EM);
//_fpreset();
//_clear87();
try
{
throw Exception("dfg");
}
catch(...)
{
}
{
std::stringstream stream;
std::string str;
double d(1.0);
stream << std::setprecision(16);
stream << d << '\n';
stream>>str;
ShowMessage(str.c_str());
}
-------------------------------
The second message shows 0.000000000027.......
Reseting or clearing the FPU mask does not help...
Well, I need "_control87(MCW_EM,MCW_EM);" (using some special DirectX
features)
Can anybody help?
Greetings Kirsten
 
 

Re:First exception puzzles FPU (_control87)?

Hi @all,
I am using BCB 6.0 and I have a problem using _control87(...). After an
exception (no matter which one) conversion between string and double
are handled totally wrong.
Please try the following piece of code:
---------------
#include <iostream>
#include <iomanip>
#include <sstream>
#include <float.h>
void test()
{
{
std::stringstream stream;
std::string str;
double d(1.0);
stream << std::setprecision(16);
stream << d << '\n';
stream>>str;
ShowMessage(str.c_str());
}
_control87(MCW_EM,MCW_EM);
//_fpreset();
//_clear87();
try
{
throw Exception("dfg");
}
catch(...)
{
}
{
std::stringstream stream;
std::string str;
double d(1.0);
stream << std::setprecision(16);
stream << d << '\n';
stream>>str;
ShowMessage(str.c_str());
}
}
-------------------------------
The second message shows 0.000000000027.......
Reseting or clearing the FPU mask does not help...
Well, I need "_control87(MCW_EM,MCW_EM);" (using some special DirectX
features)
Can anybody help?
Greetings Kirsten