Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
12.7 and narrowing signed integers
#1
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.
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>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)