how to change unsigned long to char?
what I expect:
res[0] = 78
res[1] = 65
res[2] = 34
res[3] = 12
But I can't get the correct value. Why?
Rich (BB code):
unsigned long currentData = 12345678;
char res[4];
res[0] = currentData & 0x000000FF;
res[1] = (currentData & 0x0000FF00) >>8;
res[2] = (currentData & 0x00FF0000) >>16;
res[3] = (currentData & 0xFF000000) >>24;
res[0] = 78
res[1] = 65
res[2] = 34
res[3] = 12
But I can't get the correct value. Why?