31-08-2010, 09:19 PM
I have a question concerning Rule 12.7: Bitwise operators shall not be applied to operands whose underlying type is signed.
I need to transmit a 7-bit signed integer (values are restricted -64 - +63). My current method, shown below, seems to be inconsistent with 12.7.
Is the following an acceptable solution, or a violation of 10.1? Do I need to use a deviation here for the 7-bit integer?
Thank you for your help!
I need to transmit a 7-bit signed integer (values are restricted -64 - +63). My current method, shown below, seems to be inconsistent with 12.7.
Code:
int_8 s8a;
uint_8 u8b;
...
u8b = s8a & 0x7F;
Is the following an acceptable solution, or a violation of 10.1? Do I need to use a deviation here for the 7-bit integer?
Code:
int_8 s8a;
uint_8 u8b;
...
u8b = ((uint_8)s8a & 0x7F;
Thank you for your help!
<t></t>