double to bytes / hex - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

double to bytes / hex

hi i have 0.1234 double
i want to see representation in hex and in bytes how to do it

Comments

  • Griz803Griz803 Posts: 100Member
    : hi i have 0.1234 double
    : i want to see representation in hex and in bytes how to do it
    :
    You don't specify whether it is in C or C++. In C, check out the printf function and the ANSII format specifiers. In C++, read up on iostream and the cout object. Hope this helps.
  • michaeldunemichaeldune Posts: 103Member
    : : hi i have 0.1234 double
    : : i want to see representation in hex and in bytes how to do it
    : :
    : You don't specify whether it is in C or C++. In C, check out the printf function and the ANSII format specifiers. In C++, read up on iostream and the cout object. Hope this helps.
    :
    i can use c++
    the problem is that i transfer the value to other program
    i convert the double to array of 8 chars what occurs is
    xxxx00yy
    becuse i have the 2 zeros the number ends and the yy disppaeres i suppose the program thinks it is null teminator how i can avoid this
  • stephlstephl Posts: 422Member
    : : : hi i have 0.1234 double
    : : : i want to see representation in hex and in bytes how to do it
    : : :
    : : You don't specify whether it is in C or C++. In C, check out the printf function and the ANSII format specifiers. In C++, read up on iostream and the cout object. Hope this helps.
    : :
    : i can use c++
    : the problem is that i transfer the value to other program
    : i convert the double to array of 8 chars what occurs is
    : xxxx00yy
    : becuse i have the 2 zeros the number ends and the yy disppaeres i suppose the program thinks it is null teminator how i can avoid this
    :
    I'm far from being a specialist, however I think this should work.
    [code]#include


    int main(void)
    {
    double dv;
    char *sv;
    int i;

    dv=0.1234;
    sv=(char *) &dv;
    printf("sv -> ");
    for (i=0;i<sizeof (double);++i)
    printf("%x ",sv[i]);
    printf("
    ");
    return 0;
    }[/code]

    Take care, Steph.
Sign In or Register to comment.