The tilde operator in C

后端 未结 6 719
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-28 09:17

I\'ve seen the tilde operator used in the ELF hashing algorithm, and I\'m curious what it does. (The code is from Eternally Confused.)

unsigned elf_hash ( vo         


        
6条回答
  •  难免孤独
    2020-11-28 09:48

    The tilde character is used as an operator to invert all bits of an integer (bitwise NOT).

    For example: ~0x0044 = 0xFFBB.

提交回复
热议问题