Snippet Library
Browse | Submit A New Snippet | Create A Package
Decimal Empaquetado | |
| Type: Function |
Category: Math Functions |
| License: GNU General Public License |
Language: C |
| Description: Algoritmo de empaquetamientos de decimales. | |
Versions Of This Snippet:
| Snippet ID | Download Version | Date Posted | Author | Delete |
|---|---|---|---|---|
| 11 | 1.0 | 2005-04-22 04:19 | Andres Ovalle |
Download a raw-text version of this code by clicking on "Download Version"
Latest Snippet Version: 1.0
#include <stdio.h> #define dig 7 #define emp 4 unsigned char* empaquetadox(unsigned char digito[]) { unsigned static char result[emp]; int index_emp,index_dig,i; for(index_emp=0;index_emp<emp;index_emp++) result[index_emp]=' '; result[emp-1]='\0'; if(digito[0]=='+') result[emp-2]=0x0C; else result[emp-2]=0x0D; result[emp-2]+=(digito[dig-2]-0x30)*0x10; for(index_emp=emp-3,index_dig=dig-3;index_dig>0;index_emp--,index_dig--) { result[index_emp]=(digito[index_dig]-0x30); index_dig--; if(index_dig>0) result[index_emp]+=(digito[index_dig]-0x30)*0x10; } for(index_emp=emp-2;index_emp>=0;index_emp--) printf("hex emp[%d] %x\n",index_emp,result[index_emp]); return result; } void main() { int i,k; unsigned char a[dig]="+12345"; printf("digito empaquetadox %s\n",empaquetadox(a)); scanf("%d",&k); }
Submit a new version
You can submit a new version of this snippet if you have modified it and you feel it is appropriate to share with others..

