www.pudn.com > 17551_portion.rar > methoda.cpp
#include "stdafx.h" #include "GPIOCTL.h" #include#include "methoda.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif void Cmethoda::tenTotwo(int *a, int b) { int x; char sign; char i; for (x=0;x1) { c=c*e; --d; } return c; } void Cmethoda::bitTOchar(unsigned char *value, int bitcount,int bitvalue) { if(bitcount>7||bitcount<0||bitvalue>1||bitvalue<0) { return; } int bit[8]={0,0,0,0,0,0,0,0}; int *p; p=bit; tenTotwo(p,*value); bit[bitcount]=bitvalue; *value=twoTOten(p); } void Cmethoda::not(int *bit) { if(*bit>1||*bit<0) { return; } if(*bit==0) { *bit=1; return; } if(*bit==1) { *bit=0; return; } } int Cmethoda::readbitfromchar(unsigned char *valuea, int bitcount) { if(bitcount>7||bitcount<0) { return 2;//´íÎóÔò·µ»Ø2 } int bit[8]={0,0,0,0,0,0,0,0}; int *p; p=bit; tenTotwo(p,*valuea); return bit[bitcount]; }