解释c++中非规范化双精度对象的输出
Interprete the print out of a denormalized double in C++
当c++程序打印出以下数字时,这是什么意思?最后的H是什么意思?
-6.38442 e - 86 h
整个系统太大,不能在这里添加,但是这里是打印特定双精度数的代码。
try{
newLogLikelihoodEM= hmm->learningLogLikelihood(data, Arglist::getDiffLogLikelihood(), fileNumbers, rng);
}
catch (SingularCovarianceMatrixException &scme)
{
std::cout << scme.what() << ": doing learning, so restarts for this start-point" << std::endl;
noRestarts++;
restart = true;
}
和异常类
class SingularCovarianceMatrixException: public std::exception
{
double det;
public:
SingularCovarianceMatrixException(double det):det(det){};
virtual const char* what() const throw()
{
std::stringstream msg;
msg<< "Singular covariance matrix: determinant="<<det;
return msg.str().c_str();
}
};
异常由
抛出if(*detCovarianceMatrix<1e-300)
{
throw SingularCovarianceMatrixException(*detCovarianceMatrix);
}
H
不属于数字。这不是浮点数的有效后缀。在你的代码中应该有别的东西打印它
H
不是一个有效的浮点后缀,我找不到一个很好的参考来证明这一点,但我们可以显示它不是一个有效的转换使用这个代码:
#include <iostream>
#include <sstream>
#include <string>
#include <stdexcept>
class BadConversion : public std::runtime_error {
public:
BadConversion(std::string const& s)
: std::runtime_error(s)
{ }
};
inline double convertToDouble(std::string const& s,
bool failIfLeftoverChars = true)
{
std::istringstream i(s);
double x;
char c;
if (!(i >> x) || (failIfLeftoverChars && i.get(c)))
throw BadConversion("convertToDouble("" + s + "")");
return x;
}
int main()
{
double d1 = convertToDouble("-6.38442e-86") ;
std::cout << d1 << std::endl ;
d1 = convertToDouble("-6.38442e-86H");
std::cout << d1 << std::endl ;
}
这是我从我以前的一个关于如何检查string
是否为integer
的答案中的代码。
相关文章:
- 无法输出对象的红色/绿色/蓝色值
- 为对象分配整数.输出将是什么?
- 为什么两种不同的对象初始化方式给出不同的输出
- 尝试重载输出运算符时,我无法遍历对象向量
- 如何在 c++ 中使用 for 循环输出矢量中的所有对象
- IM 试图显示对象数组,但它给出了错误的输出
- C++对象数组的文件输出
- OBJDUMP给出了具有和没有-fpic的对象文件的相同输出
- 我使用箭头运算符打印出对象的变量值,并得到一些随机值作为输出
- 对象实例化后不输出
- 打印对象矢量的意外输出
- 具有GSOAP的序列化对象,以验证Web服务输出
- 当将对象传递给具有参数作为引用类型的函数以及当其类对象类型时,会得到不同的输出
- C++ 如何将结构化 git 日志的输出解析为对象
- C++输出对象中的所有成员
- 无法输出线条C++的对象点
- OpenCV程序的输出在未检测到文本对象时不给出0
- 在返回之前等待输出的自定义QProcess对象
- "make"的输出是一个共享对象,而不是可执行文件
- OpenCV,Dlib - 作为黑色图像输出的垫子对象