H
is not part of the number. This is not a valid suffix for a floating point number. Something else in your code should be printing it.
Interprete the print out of a denormalized double in C++
-
14-04-2022 - |
Question
What does it mean when a C++ program prints the following number out, and what is the meaning of the H in the end?
-6.38442e-86H
The entire system is too large to add here, however here is the code that printed out the particular double.
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;
}
and the exception class
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();
}
};
And the exception is thrown by
if(*detCovarianceMatrix<1e-300)
{
throw SingularCovarianceMatrixException(*detCovarianceMatrix);
}
Solution
OTHER TIPS
H
is not a valid floating point suffix, I can not find a good reference to prove this but we can show that it is not a valid conversion using this code:
#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 ;
}
Which is code I took from one of my previous answers on how to check if a string
is an integer
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow