相关疑难解决方法(0)

C中的波浪号运算符

我已经看到了ELF哈希算法中使用的波浪号运算符,我很好奇它的作用.(代码来自Eternally Confused.)

unsigned elf_hash ( void *key, int len )
{
  unsigned char *p = key;
  unsigned h = 0, g;
  int i;

  for ( i = 0; i < len; i++ ) {
    h = ( h << 4 ) + p[i];
    g = h & 0xf0000000L;

    if ( g != 0 )
      h ^= g >> 24;

    h &= ~g;
  }

  return h;
}
Run Code Online (Sandbox Code Playgroud)

c c++ operators

88
推荐指数
5
解决办法
7万
查看次数

标签 统计

c ×1

c++ ×1

operators ×1