Hex to IEEE format

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gnanapoongothai
    New Member
    • Jun 2007
    • 62

    Hex to IEEE format

    is ther any function in c or vc++ to convert the hex value to floating point value as per ieee format. i searched google but confused with the result what actuallt they do.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Use a stringstream:

    [code=cpp]
    stringstream ss;
    ss << 0X1A;
    double result;
    ss >> result;
    cout << result << endl;

    //Or use a string
    ss.flush();
    string str("0x1A");
    ss << str;
    ss >> result;
    cout << result << endl;
    [/code]

    Comment

    • gnanapoongothai
      New Member
      • Jun 2007
      • 62

      #3
      Hi,
      Thanks for ur reply. But u havent mentioned what is the value of result and i hope the ss is the hex format value.

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        result is a double. The hex value is in the double.

        ss is a stringstream object. You may want to refresh your memory about this type.

        Try the code.

        Comment

        Working...