⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ilog2.c

📁 shpf 1.9一个并行编译器
💻 C
字号:
//======================================================================
// NPAC $Id: ilog2.C,v 1.1 1996/09/23 22:34:31 dbc Exp $
//======================================================================

int ilog2(int n) {

// _____________________________________________________________________
//|                                                                     |
//| Function to return the base-2 logarithm of an integer.              |
//|                                                                     |
//| H W Yau.  30th of January, 1994.                                    |
//| Northeast Parallel Architectures Center.                            |
//| Syracuse University.                                                |
//|_____________________________________________________________________|
//|                                                                     |
//| Edit record:                                                        |
//| 30/Jan/1995: First edit.                                            |
//| 16/Feb/1995: Removed PURE declaration of this function, PGI does    |
//|              not like it.                                           |
//| 20/Aug/1996: PGI Compiler now likes PURE attribute to function.     |
//|_____________________________________________________________________|

  int i, n2, result ;

  n2     = n ;
  result = 0 ;
  for(i = 1 ; i <= n ; i++) {
    if(n2 > 1) {
      result = result + 1 ;
      n2 = n2 / 2 ;
    }
    else {
      return result ;
    }
  }
}

//======================================================================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -