1

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);
}
Morten
  • 2,148
  • 2
  • 15
  • 16
  • 5
    Can you add the code that is generating this output? – olevegard May 07 '13 at 13:27
  • That's not denormal; denormals start at `1.0p-1022`, ~ `2.2250738585072014e-308`. – ecatmur May 07 '13 at 14:02
  • It means that the program is doing something more than printing out the value, but there's no way to know what that is because there is no code here. – Pete Becker May 07 '13 at 14:29
  • Here is the code snippets. I don't understand how this number or the H is printed out, since it is not below 1e-300 but thanks for your help. – Morten May 07 '13 at 20:06

2 Answers2

2

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.

Ivaylo Strandjev
  • 69,226
  • 18
  • 123
  • 176
1

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.

Community
  • 1
  • 1
Shafik Yaghmour
  • 154,301
  • 39
  • 440
  • 740