Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

strange backslash operator in C assignment

Tags:

What does following 0x0\1 mean in following code? I find this in an embedded C code:

uint16 size;
...
size += (size & 0x0\1);

It's part of Texas Instruments released code. It compiles in IAR ARM IDE.

like image 838
doubleE Avatar asked Oct 26 '16 02:10

doubleE


1 Answers

Non-portable, implementation dependent, non-standard conforming code. It is anybody's guess what the original author has intended but "probably" means size += size & 0x1. That is: increment size by 1 in case size is odd (that is, least significant bit is 1).

like image 157
teroi Avatar answered Sep 23 '22 16:09

teroi