I am new to shifting bits, but I am trying to debug the following snippet:
if (!(strcmp(arr[i].GetValType(), "f64")))
{
dem_content_buff[BytFldPos] = tmp_data;
dem_content_buff[BytFldPos + 1] = tmp_data >> 8;
dem_content_buff[BytFldPos + 2] = tmp_data >> 16;
dem_content_buff[BytFldPos + 3] = tmp_data >> 24;
dem_content_buff[BytFldPos + 4] = tmp_data >> 32;
dem_content_buff[BytFldPos + 5] = tmp_data >> 40;
dem_content_buff[BytFldPos + 6] = tmp_data >> 48;
dem_content_buff[BytFldPos + 7] = tmp_data >> 56;
}
I am getting a warning saying the lines with "32" to "56" have a shift count that is too large. The "f64" in the predicate just means that the data should be 64bit data.
How should this be done?
edit:
I should have put more of the code in.
tmp_data = simulated_data[index_data];
if (!(strcmp(dems[i].GetValType(), "s32")))
{
dem_content_buff[BytFldPos] = tmp_data;
dem_content_buff[BytFldPos + 1] = tmp_data >> 8;
dem_content_buff[BytFldPos + 2] = tmp_data >> 16;
dem_content_buff[BytFldPos + 3] = tmp_data >> 24;
}
if (!(strcmp(dems[i].GetValType(), "f64"))) { dem_content_buff[BytFldPos] = tmp_data; dem_content_buff[BytFldPos + 1] = tmp_data >> 8; dem_content_buff[BytFldPos + 2] = tmp_data >> 16; dem_content_buff[BytFldPos + 3] = tmp_data >> 24; dem_content_buff[BytFldPos + 4] = tmp_data >> 32; dem_content_buff[BytFldPos + 5] = tmp_data >> 40; dem_content_buff[BytFldPos + 6] = tmp_data >> 48; dem_content_buff[BytFldPos + 7] = tmp_data >> 56; }
So, dem_content_buff
right now only holds ints. Can I not use this array for the 64 bit data either?