Ste*_*ves 1 c c++ type-conversion visual-c++
我想在使用strtod函数在C++(Visual C++ 2010)中将字符串转换为double时检测下溢.下面的代码不能像我期望的那样工作,尽管我是根据strtod文档做的:
char numStr[] = "123456.122111111123123123123132123123123123123124434345345";
char* pEnd;
double d = strtod(numStr, &pEnd);
int errorNum = errno;
if (errorNum == ERANGE) // this should be true
{
// underflow occurred
}
Run Code Online (Sandbox Code Playgroud)
使用调试器,我发现errorNum总是被设置为0与ERANGE是34.
我错过了什么?
| 归档时间: |
|
| 查看次数: |
663 次 |
| 最近记录: |