- /*
- in:
- *pnum: the address of data to convert
- *size:size of the data
- *modify:to add some decorate
- */
- void printBinary(char* pnum,int size=1,bool modify=true){
- for(int i=size-1;i>=0;i--){
- for(int j=7;j>=0;j--){
- if((*(pnum+i))&(1<<j))cout<<"1";
- else cout<<"0";
- if(modify&&j==4)cout<<"-";
- }
- if(modify)cout<<" ";
- }
- }
转载于:https://blog.51cto.com/2782138/781663