A
Allan Rydberg
hi
i'm trying to shift a double, but i'm getting the
error message '>>' illegal, left operand double.
althought that the manpages say, '>>' and '<<' can
be applied for int's only, i was able to use the
shift operator on unsigned longs without any problems.
does anyone know how to do this properly?
i.e. individually copying bytes into a long array:
--------------------------------
int pointer;
char databuffer[100];
double uint64;
unsigned long uint32;
pointer =0;
// this works:
uint32 = 1111111; // anything
databuffer[pointer++] = uint32 >> 24;
databuffer[pointer++] = uint32 >> 16;
databuffer[pointer++] = uint32 >> 8;
databuffer[pointer++] = uint32 >> 0; // jup, i know..!
// this won't:
uint64 = 1111111; // anything
databuffer[pointer++] = uint64 >> 56;
databuffer[pointer++] = uint64 >> 48;
databuffer[pointer++] = uint64 >> 40;
databuffer[pointer++] = uint64 >> 32;
databuffer[pointer++] = uint64 >> 24;
databuffer[pointer++] = uint64 >> 16;
databuffer[pointer++] = uint64 >> 8;
databuffer[pointer++] = uint64 >> 0;
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
i'm trying to shift a double, but i'm getting the
error message '>>' illegal, left operand double.
althought that the manpages say, '>>' and '<<' can
be applied for int's only, i was able to use the
shift operator on unsigned longs without any problems.
does anyone know how to do this properly?
i.e. individually copying bytes into a long array:
--------------------------------
int pointer;
char databuffer[100];
double uint64;
unsigned long uint32;
pointer =0;
// this works:
uint32 = 1111111; // anything
databuffer[pointer++] = uint32 >> 24;
databuffer[pointer++] = uint32 >> 16;
databuffer[pointer++] = uint32 >> 8;
databuffer[pointer++] = uint32 >> 0; // jup, i know..!
// this won't:
uint64 = 1111111; // anything
databuffer[pointer++] = uint64 >> 56;
databuffer[pointer++] = uint64 >> 48;
databuffer[pointer++] = uint64 >> 40;
databuffer[pointer++] = uint64 >> 32;
databuffer[pointer++] = uint64 >> 24;
databuffer[pointer++] = uint64 >> 16;
databuffer[pointer++] = uint64 >> 8;
databuffer[pointer++] = uint64 >> 0;
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]