diff options
author | siddhu8990 | 2017-04-19 14:57:49 +0530 |
---|---|---|
committer | siddhu8990 | 2017-04-19 14:57:49 +0530 |
commit | b9cfdca438347fe4d28f7caff3cb7b382e455d3a (patch) | |
tree | 948593b7d89741f804919a74f2e5e34b39adb0a0 /2.3-1/src/c/elementaryFunctions/radix_conversions/hex2dec/ghex2decs.c | |
parent | 586db6343e7b472d8dc3e63a82f4c73f99cdcbd7 (diff) | |
download | Scilab2C-b9cfdca438347fe4d28f7caff3cb7b382e455d3a.tar.gz Scilab2C-b9cfdca438347fe4d28f7caff3cb7b382e455d3a.tar.bz2 Scilab2C-b9cfdca438347fe4d28f7caff3cb7b382e455d3a.zip |
Merged Shamik's work
Diffstat (limited to '2.3-1/src/c/elementaryFunctions/radix_conversions/hex2dec/ghex2decs.c')
-rw-r--r-- | 2.3-1/src/c/elementaryFunctions/radix_conversions/hex2dec/ghex2decs.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/hex2dec/ghex2decs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/hex2dec/ghex2decs.c new file mode 100644 index 00000000..c5b68dbc --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/hex2dec/ghex2decs.c @@ -0,0 +1,81 @@ +#include <string.h> +#include "hex2dec.h" +#include <stdio.h> +#include <math.h> + +double ghex2decs(char* in,int size) +{ + size-=2; + int i=0,val=0,j=0; + double o=0.0; + for(i=0; in[i]!='\0'; i++) + { +/* Finds the decimal equivalent of each hexadecimal digit +*/ + switch(in[i]) + { + case '0': + val = 0; + break; + case '1': + val = 1; + break; + case '2': + val = 2; + break; + case '3': + val = 3; + break; + case '4': + val = 4; + break; + case '5': + val = 5; + break; + case '6': + val = 6; + break; + case '7': + val = 7; + break; + case '8': + val = 8; + break; + case '9': + val = 9; + break; + case 'a': + case 'A': + val = 10; + break; + case 'b': + case 'B': + val = 11; + break; + case 'c': + case 'C': + val = 12; + break; + case 'd': + case 'D': + val = 13; + break; + case 'e': + case 'E': + val = 14; + break; + case 'f': + case 'F': + val = 15; + break; + } + o = o + (val * pow(16, size)); + //printf("%f\n",out[0]); + //o=(int)out[0]; + //o=o/16; + //printf("%d %d %d\n",o,val,(val * pow(16, size))); + //j++; + size--; + } + return o; + } |