library.c

来自「This a framework to test new ideas in tr」· C语言 代码 · 共 55 行

C
55
字号
/*************************************************************************** *    function_name.c  - Software Radio template module *                           ------------------- *   begin                :  date *   authors              :  name *   emails               :  email address ***************************************************************************//*************************************************************************** *                                Changes *                                ------- * date - name - description * **************************************************************************//*************************************************************************** *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * ***************************************************************************/#include "library.h"/** * Please see header file for description */int countOnes(REG_STATUS in,int numBits) {  REG_STATUS chkMask=0x01;  int ctr=0;  int i;  //only bits 0..numBits are relevant (rest unused)  for (i=0;i<numBits;i++) {    //Check if a one was found    if ((in & chkMask) !=0)      ctr++;    //Shift mask to check next bit    chkMask<<=1;  }  return ctr;}/** * Please see header file for description */int hammingDistance(REG_STATUS input1,REG_STATUS input2,int numBits) {  //hamming distance is the number of 1-Bits of the XOR of the two values  return countOnes(input1^input2,numBits);}

⌨️ 快捷键说明

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