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

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.