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 | |
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')
58 files changed, 1347 insertions, 0 deletions
diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/base2dec/dbase2decs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/base2dec/dbase2decs.c new file mode 100644 index 00000000..51c42e02 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/base2dec/dbase2decs.c @@ -0,0 +1,21 @@ +#include <string.h> +#include "base2dec.h" +#include <stdio.h> +#include <math.h> + +double dbase2decs(double in,int base) +{ + int n=0,rem=0, base1=1; + double out=0.0; + n=(int)in; + while (n!=0) + { + rem = n%10; + out = out + (rem * base1); + n = n / 10 ; + base1 = base1 * base; + } + return out; +} + + diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/base2dec/gbase2decs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/base2dec/gbase2decs.c new file mode 100644 index 00000000..9acf2666 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/base2dec/gbase2decs.c @@ -0,0 +1,160 @@ +#include<stdio.h> +#include<math.h> +#include "base2dec.h" +#include <string.h> + +double gbase2decs(char* in,int size,int base) +{ + size-=2; + int i=0,val=0,j=0; + double o=0.0; + for(i=0; in[i]!='\0'; i++) + { + //printf("%c \n",in[i]); + 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; + case 'g': + case 'G': + val = 16; + break; + case 'h': + case 'H': + val = 17; + break; + case 'i': + case 'I': + val = 18; + break; + case 'j': + case 'J': + val = 19; + break; + case 'k': + case 'K': + val = 20; + break; + case 'l': + case 'L': + val = 21; + break; + case 'm': + case 'M': + val = 22; + break; + case 'n': + case 'N': + val = 23; + break; + case 'o': + case 'O': + val = 24; + break; + case 'p': + case 'P': + val = 25; + break; + case 'q': + case 'Q': + val = 26; + break; + case 'r': + case 'R': + val = 27; + break; + case 's': + case 'S': + val = 28; + break; + case 't': + case 'T': + val = 29; + break; + case 'u': + case 'U': + val = 30; + break; + case 'v': + case 'V': + val = 31; + break; + case 'w': + case 'W': + val = 32; + break; + case 'x': + case 'X': + val = 33; + break; + case 'y': + case 'Y': + val = 34; + break; + case 'z': + case 'Z': + val = 35; + break; + } + o = o + (val * pow(base, 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; + } diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/dbin2deca.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/dbin2deca.c new file mode 100644 index 00000000..9baf4bda --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/dbin2deca.c @@ -0,0 +1,10 @@ +#include "bin2dec.h" + +void dbin2deca(double* in,int size,double* out) +{ + int i=0; + for(i=0;i<size;i++) + { + out[i]=dbin2decs(in[i]); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/dbin2decs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/dbin2decs.c new file mode 100644 index 00000000..1d3cf3aa --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/dbin2decs.c @@ -0,0 +1,21 @@ +#include <string.h> +#include "bin2dec.h" +#include <stdlib.h> +#include <stdio.h> +long double dbin2decs(long double in) +{ + int base=1, rem=0; + long double out=0.0; + int in1; + in1=(int)in; + while (in1 != 0) + { + rem = in1 % 10; + out = out + (rem * base); + in1 = in1 / 10 ; + base = base * 2; + } + return out; + // printf("Decimal equivalent is: %f \n",out); +} + diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/i16bin2deca.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/i16bin2deca.c new file mode 100644 index 00000000..1ebc973c --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/i16bin2deca.c @@ -0,0 +1,10 @@ +#include "bin2dec.h" + +void i16bin2deca(int16* in,int size,int16* out) +{ + int i=0; + for(i=0;i<size;i++) + { + out[i]=i16bin2decs(in[i]); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/i16bin2decs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/i16bin2decs.c new file mode 100644 index 00000000..0f395416 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/i16bin2decs.c @@ -0,0 +1,21 @@ +#include <string.h> +#include "bin2dec.h" +#include <stdlib.h> +#include <stdio.h> +int16 i16bin2decs(int16 in) +{ + int base=1, rem=0; + int16 out=0; + int in1; + in1=(int)in; + while (in1 != 0) + { + rem = in1 % 10; + out = out + (rem * base); + in1 = in1 / 10 ; + base = base * 2; + } + return out; + // printf("Decimal equivalent is: %f \n",out); +} + diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/i8bin2deca.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/i8bin2deca.c new file mode 100644 index 00000000..ad76143e --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/i8bin2deca.c @@ -0,0 +1,10 @@ +#include "bin2dec.h" + +void i8bin2deca(int8* in,int size,int8* out) +{ + int i=0; + for(i=0;i<size;i++) + { + out[i]=i8bin2decs(in[i]); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/i8bin2decs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/i8bin2decs.c new file mode 100644 index 00000000..1863e51a --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/i8bin2decs.c @@ -0,0 +1,21 @@ +#include <string.h> +#include "bin2dec.h" +#include <stdlib.h> +#include <stdio.h> +int8 i8bin2decs(int8 in) +{ + int base=1, rem=0; + int8 out=0; + int in1; + in1=(int)in; + while (in1 != 0) + { + rem = in1 % 10; + out = out + (rem * base); + in1 = in1 / 10 ; + base = base * 2; + } + return out; + // printf("Decimal equivalent is: %f \n",out); +} + diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/u16bin2deca.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/u16bin2deca.c new file mode 100644 index 00000000..2a4ac15d --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/u16bin2deca.c @@ -0,0 +1,10 @@ +#include "bin2dec.h" + +void u16bin2deca(uint16* in,int size,uint16* out) +{ + int i=0; + for(i=0;i<size;i++) + { + out[i]=u16bin2decs(in[i]); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/u16bin2decs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/u16bin2decs.c new file mode 100644 index 00000000..0e58b94f --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/u16bin2decs.c @@ -0,0 +1,21 @@ +#include <string.h> +#include "bin2dec.h" +#include <stdlib.h> +#include <stdio.h> +uint16 u16bin2decs(uint16 in) +{ + int base=1, rem=0; + uint16 out=0; + int in1; + in1=(int)in; + while (in1 != 0) + { + rem = in1 % 10; + out = out + (rem * base); + in1 = in1 / 10 ; + base = base * 2; + } + return out; + // printf("Decimal equivalent is: %f \n",out); +} + diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/u8bin2deca.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/u8bin2deca.c new file mode 100644 index 00000000..f775664c --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/u8bin2deca.c @@ -0,0 +1,10 @@ +#include "bin2dec.h" + +void u8bin2deca(uint8* in,int size,uint8* out) +{ + int i=0; + for(i=0;i<size;i++) + { + out[i]=u8bin2decs(in[i]); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/u8bin2decs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/u8bin2decs.c new file mode 100644 index 00000000..41986007 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/bin2dec/u8bin2decs.c @@ -0,0 +1,21 @@ +#include <string.h> +#include "bin2dec.h" +#include <stdlib.h> +#include <stdio.h> +uint8 u8bin2decs(uint8 in) +{ + int base=1, rem=0; + uint8 out=0; + int in1; + in1=(int)in; + while (in1 != 0) + { + rem = in1 % 10; + out = out + (rem * base); + in1 = in1 / 10 ; + base = base * 2; + } + return out; + // printf("Decimal equivalent is: %f \n",out); +} + diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2base/ddec2basea.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2base/ddec2basea.c new file mode 100644 index 00000000..eeadcb76 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2base/ddec2basea.c @@ -0,0 +1,10 @@ +#include "dec2base.h" + +void ddec2basea(double* in,int size,int base,int n,char* out) +{ + int i=0; + for(i=0;i<size;i++) + { + ddec2bases(in[i],base,n,&(out[i*3])); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2base/ddec2bases.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2base/ddec2bases.c new file mode 100644 index 00000000..9dc7c82e --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2base/ddec2bases.c @@ -0,0 +1,60 @@ +#include <string.h> +#include <math.h> +#include "dec2base.h" +#include <stdio.h> + +void ddec2bases(double in,int base,int n,char* out) +{ + int quot; + //printf("%d\n",n); + int i=0,j=0,k=0,tmp,temp; + quot=(int)in; + //printf("%d",quot); + while(quot!=0) + { + temp=quot%base; + //printf("%d\n",temp); + if(temp < 10) + { temp = temp + 48; + //printf("%d\n",temp); + } + else + { + temp = temp + 55; + //printf("%d\n",temp); + } + out[i++]=temp; + //printf("%c\n",out[i-1]); + quot = quot/base; + } +//printf("%d\n",i); + if(n>i-1) + { + for(j=i;j<=n;j++) + { out[j]='0'; + //printf(" %c %c \n",out[j],out[i]); + } + } + if(n==0) + { + j=i-1; + n=i; + } + else + j=n-1; + + out[n]='\0'; + //for(k=0;k<=n;k++) + //printf("%c\n",out[k]); + i=0; + while(i<j) + { + tmp=out[i]; + //printf("%c\n",out[i]); + out[i]=out[j]; + out[j]=tmp; + //printf("%c\n",out[j]); + i++; + j--; + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2base/sdec2basea.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2base/sdec2basea.c new file mode 100644 index 00000000..51e12388 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2base/sdec2basea.c @@ -0,0 +1,10 @@ +#include "dec2base.h" + +void sdec2basea(float* in,int size,int base,int n,char* out) +{ + int i=0; + for(i=0;i<size;i++) + { + sdec2bases(in[i],base,n,&(out[i*3])); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2base/sdec2bases.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2base/sdec2bases.c new file mode 100644 index 00000000..9abe2168 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2base/sdec2bases.c @@ -0,0 +1,34 @@ +#include <string.h> +#include <math.h> +#include "dec2base.h" +#include <stdio.h> + +void sdec2bases(float in,int base,int n,char* out) +{ + int quot; + int i=0,j=0,k=0,tmp,temp; + quot=(int)in; + while(quot!=0) + { + temp=quot%base; + if(temp < 10) + temp = temp + 48; + else + temp = temp + 55; + out[i++]=temp; + quot = quot/base; + } + out[i]='\0'; + j=i-1; + i=0; + while(i<j) + { + tmp=out[i]; + out[i]=out[j]; + out[j]=tmp; + i++; + j--; + } + + +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/ddec2bina.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/ddec2bina.c new file mode 100644 index 00000000..e0648758 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/ddec2bina.c @@ -0,0 +1,10 @@ +#include "dec2bin.h" + +void ddec2bina(double* in,int size,int n,double* out) +{ + int i=0; + for(i=0;i<size;i++) + { + ddec2bins(in[i],n,&(out[i*15])); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/ddec2bins.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/ddec2bins.c new file mode 100644 index 00000000..c97fc428 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/ddec2bins.c @@ -0,0 +1,39 @@ +#include <string.h> +#include "dec2bin.h" +#include <stdio.h> +void ddec2bins(double in,int n,double* out) +{ + int quotient,i=0,j=0,tmp=0; + quotient=(int)in; + for(i=0;i<n;i++) + { + out[i]=0.0; + } + i=0; + while(quotient!=0) + { + out[i++]= quotient%2; + quotient=quotient/2; + } + if(n>i-1) + { + for(j=i;j<=n;j++) + out[j]=0.0; + } + if(n==0) + j=i-1; + else + j=n-1; + + i=0; + + while(i<j) + { + tmp=out[i]; + //printf("%f",tmp); + out[i]=out[j]; + out[j]=tmp; + i++; + j--; + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/i16dec2bina.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/i16dec2bina.c new file mode 100644 index 00000000..1fa251c7 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/i16dec2bina.c @@ -0,0 +1,10 @@ +#include "dec2bin.h" + +void i16dec2bina(int16* in,int size,int n,int16* out) +{ + int i=0; + for(i=0;i<size;i++) + { + i16dec2bins(in[i],n,&(out[i*15])); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/i16dec2bins.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/i16dec2bins.c new file mode 100644 index 00000000..0b06aef1 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/i16dec2bins.c @@ -0,0 +1,32 @@ +#include <string.h> +#include "dec2bin.h" +#include <stdio.h> +void i16dec2bins(int16 in,int n,int16* out) +{ + int quotient,i=0,j=0,tmp=0; + quotient=(int)in; + while(quotient!=0) + { + out[i++]= quotient%2; + quotient=quotient/2; + } + if(n>i-1) + { + for(j=i;j<=n;j++) + out[j]=0.0; + } + if(n==0) + j=i-1; + else + j=n-1; + i=0; + + while(i<j) + { + tmp=out[i]; + out[i]=out[j]; + out[j]=tmp; + i++; + j--; + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/i8dec2bina.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/i8dec2bina.c new file mode 100644 index 00000000..2297ae9d --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/i8dec2bina.c @@ -0,0 +1,10 @@ +#include "dec2bin.h" + +void i8dec2bina(int8* in,int size,int n,int8* out) +{ + int i=0; + for(i=0;i<size;i++) + { + i8dec2bins(in[i],n,&(out[i*15])); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/i8dec2bins.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/i8dec2bins.c new file mode 100644 index 00000000..4f4024c9 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/i8dec2bins.c @@ -0,0 +1,32 @@ +#include <string.h> +#include "dec2bin.h" +#include <stdio.h> +void i8dec2bins(int8 in,int n,int8* out) +{ + int quotient,i=0,j=0,tmp=0; + quotient=(int)in; + while(quotient!=0) + { + out[i++]= quotient%2; + quotient=quotient/2; + } + if(n>i-1) + { + for(j=i;j<=n;j++) + out[j]=0.0; + } + if(n==0) + j=i-1; + else + j=n-1; + i=0; + + while(i<j) + { + tmp=out[i]; + out[i]=out[j]; + out[j]=tmp; + i++; + j--; + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/u16dec2bina.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/u16dec2bina.c new file mode 100644 index 00000000..153ce863 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/u16dec2bina.c @@ -0,0 +1,10 @@ +#include "dec2bin.h" + +void u16dec2bina(uint16* in,int size,int n,uint16* out) +{ + int i=0; + for(i=0;i<size;i++) + { + u16dec2bins(in[i],n,&(out[i*15])); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/u16dec2bins.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/u16dec2bins.c new file mode 100644 index 00000000..1ade60f4 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/u16dec2bins.c @@ -0,0 +1,32 @@ +#include <string.h> +#include "dec2bin.h" +#include <stdio.h> +void u16dec2bins(uint16 in,int n,uint16* out) +{ + int quotient,i=0,j=0,tmp=0; + quotient=(int)in; + while(quotient!=0) + { + out[i++]= quotient%2; + quotient=quotient/2; + } + if(n>i-1) + { + for(j=i;j<=n;j++) + out[j]=0.0; + } + if(n==0) + j=i-1; + else + j=n-1; + i=0; + + while(i<j) + { + tmp=out[i]; + out[i]=out[j]; + out[j]=tmp; + i++; + j--; + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/u8dec2bina.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/u8dec2bina.c new file mode 100644 index 00000000..87fc9187 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/u8dec2bina.c @@ -0,0 +1,10 @@ +#include "dec2bin.h" + +void u8dec2bina(uint8* in,int size,int n,uint8* out) +{ + int i=0; + for(i=0;i<size;i++) + { + u8dec2bins(in[i],n,&(out[i*15])); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/u8dec2bins.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/u8dec2bins.c new file mode 100644 index 00000000..971f6c22 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2bin/u8dec2bins.c @@ -0,0 +1,32 @@ +#include <string.h> +#include "dec2bin.h" +#include <stdio.h> +void u8dec2bins(uint8 in,int n,uint8* out) +{ + int quotient,i=0,j=0,tmp=0; + quotient=(int)in; + while(quotient!=0) + { + out[i++]= quotient%2; + quotient=quotient/2; + } + if(n>i-1) + { + for(j=i;j<=n;j++) + out[j]=0.0; + } + if(n==0) + j=i-1; + else + j=n-1; + i=0; + + while(i<j) + { + tmp=out[i]; + out[i]=out[j]; + out[j]=tmp; + i++; + j--; + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/ddec2hexa.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/ddec2hexa.c new file mode 100644 index 00000000..c3187d24 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/ddec2hexa.c @@ -0,0 +1,10 @@ +#include "dec2hex.h" + +void ddec2hexa(double* in,int size,char* out) +{ + int i=0; + for(i=0;i<size;i++) + { + ddec2hexs(in[i],&(out[i*3])); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/ddec2hexs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/ddec2hexs.c new file mode 100644 index 00000000..0adafef7 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/ddec2hexs.c @@ -0,0 +1,39 @@ +#include <string.h> +#include <math.h> +#include "dec2hex.h" +#include <stdio.h> + +void ddec2hexs(double in,char* out) +{ + int quot; + int i=0,j=0,k=0,tmp,temp; + quot=(int)in; + while(quot!=0) + { + temp=quot%16; + //To convert integer into character + if(temp < 10) + temp = temp + 48; + else + temp = temp + 55; + + out[i++]=temp; + quot = quot/16; + //printf("%c ",out[i-1]); + } + out[i]='\0'; + j=i-1; + i=0; + + while(i<j) + { + tmp=out[i]; + out[i]=out[j]; + out[j]=tmp; + i++; + j--; + } + //out[i+1]=' '; + + +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/i16dec2hexa.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/i16dec2hexa.c new file mode 100644 index 00000000..f66df8b3 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/i16dec2hexa.c @@ -0,0 +1,10 @@ +#include "dec2hex.h" + +void i16dec2hexa(int16* in,int size,char* out) +{ + int i=0; + for(i=0;i<size;i++) + { + i16dec2hexs(in[i],&(out[i*3])); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/i16dec2hexs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/i16dec2hexs.c new file mode 100644 index 00000000..f556141d --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/i16dec2hexs.c @@ -0,0 +1,38 @@ +#include <string.h> +#include <math.h> +#include "dec2hex.h" +#include <stdio.h> + +void i16dec2hexs(int16 in,char* out) +{ + int quot; + int i=0,j=0,k=0,tmp,temp; + quot=(int)in; + while(quot!=0) + { + temp=quot%16; + //To convert integer into character + if(temp < 10) + temp = temp + 48; + else + temp = temp + 55; + + out[i++]=temp; + quot = quot/16; + //printf("%c ",out[i-1]); + } + out[i]='\0'; + j=i-1; + i=0; + + while(i<j) + { + tmp=out[i]; + out[i]=out[j]; + out[j]=tmp; + i++; + j--; + } + out[i+1]=' '; + +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/i8dec2hexa.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/i8dec2hexa.c new file mode 100644 index 00000000..a6c9d94d --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/i8dec2hexa.c @@ -0,0 +1,10 @@ +#include "dec2hex.h" + +void i8dec2hexa(int8* in,int size,char* out) +{ + int i=0; + for(i=0;i<size;i++) + { + i8dec2hexs(in[i],&(out[i*3])); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/i8dec2hexs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/i8dec2hexs.c new file mode 100644 index 00000000..a5a67722 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/i8dec2hexs.c @@ -0,0 +1,39 @@ +#include <string.h> +#include <math.h> +#include "dec2hex.h" +#include <stdio.h> + +void i8dec2hexs(int8 in,char* out) +{ + int quot; + int i=0,j=0,k=0,tmp,temp; + quot=(int)in; + while(quot!=0) + { + temp=quot%16; + //To convert integer into character + if(temp < 10) + temp = temp + 48; + else + temp = temp + 55; + + out[i++]=temp; + quot = quot/16; + //printf("%c ",out[i-1]); + } + out[i]='\0'; + j=i-1; + i=0; + + while(i<j) + { + tmp=out[i]; + out[i]=out[j]; + out[j]=tmp; + i++; + j--; + } + out[i+1]=' '; + + +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/u16dec2hexa.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/u16dec2hexa.c new file mode 100644 index 00000000..52e1ae80 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/u16dec2hexa.c @@ -0,0 +1,10 @@ +#include "dec2hex.h" + +void u16dec2hexa(uint16* in,int size,char* out) +{ + int i=0; + for(i=0;i<size;i++) + { + u16dec2hexs(in[i],&(out[i*3])); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/u16dec2hexs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/u16dec2hexs.c new file mode 100644 index 00000000..1e942e63 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/u16dec2hexs.c @@ -0,0 +1,38 @@ +#include <string.h> +#include <math.h> +#include "dec2hex.h" +#include <stdio.h> + +void u16dec2hexs(uint16 in,char* out) +{ + int quot; + int i=0,j=0,k=0,tmp,temp; + quot=(int)in; + while(quot!=0) + { + temp=quot%16; + //To convert integer into character + if(temp < 10) + temp = temp + 48; + else + temp = temp + 55; + + out[i++]=temp; + quot = quot/16; + //printf("%c ",out[i-1]); + } + out[i]='\0'; + j=i-1; + i=0; + + while(i<j) + { + tmp=out[i]; + out[i]=out[j]; + out[j]=tmp; + i++; + j--; + } + out[i+1]=' '; + +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/u8dec2hexa.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/u8dec2hexa.c new file mode 100644 index 00000000..0ac48a07 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/u8dec2hexa.c @@ -0,0 +1,10 @@ +#include "dec2hex.h" + +void u8dec2hexa(uint8* in,int size,char* out) +{ + int i=0; + for(i=0;i<size;i++) + { + u8dec2hexs(in[i],&(out[i*3])); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/u8dec2hexs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/u8dec2hexs.c new file mode 100644 index 00000000..154c23f8 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2hex/u8dec2hexs.c @@ -0,0 +1,38 @@ +#include <string.h> +#include <math.h> +#include "dec2hex.h" +#include <stdio.h> + +void u8dec2hexs(uint8 in,char* out) +{ + int quot; + int i=0,j=0,k=0,tmp,temp; + quot=(int)in; + while(quot!=0) + { + temp=quot%16; + //To convert integer into character + if(temp < 10) + temp = temp + 48; + else + temp = temp + 55; + + out[i++]=temp; + quot = quot/16; + //printf("%c ",out[i-1]); + } + out[i]='\0'; + j=i-1; + i=0; + + while(i<j) + { + tmp=out[i]; + out[i]=out[j]; + out[j]=tmp; + i++; + j--; + } + out[i+1]=' '; + +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/ddec2octa.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/ddec2octa.c new file mode 100644 index 00000000..03fc2dc3 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/ddec2octa.c @@ -0,0 +1,9 @@ +#include "dec2oct.h" + +void ddec2octa(double* in,int size,double* out) +{ + int i=0; + for(i=0;i<size;i++) + { ddec2octs(in[i],&(out[i*15])); +} +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/ddec2octs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/ddec2octs.c new file mode 100644 index 00000000..d06da303 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/ddec2octs.c @@ -0,0 +1,27 @@ +#include <string.h> +#include <math.h> +#include "dec2oct.h" +#include <stdio.h> + +void ddec2octs(double in,double* out) +{ + int i=0,j=0,tmp=0; + int quotient; + quotient=(int)in; + while(quotient!=0) + { + out[i++]= quotient%8; + quotient=quotient/8; + } + j=i-1; + i=0; + + while(i<j) + { + tmp=out[i]; + out[i]=out[j]; + out[j]=tmp; + i++; + j--; + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/i16dec2octa.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/i16dec2octa.c new file mode 100644 index 00000000..882b00ba --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/i16dec2octa.c @@ -0,0 +1,10 @@ +#include "dec2oct.h" + +void i16dec2octa(int16* in,int size,int16* out) +{ + int i=0; + for(i=0;i<size;i++) + { +i16dec2octs(in[i],&(out[i*15])); +} +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/i16dec2octs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/i16dec2octs.c new file mode 100644 index 00000000..cb08845a --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/i16dec2octs.c @@ -0,0 +1,27 @@ +#include <string.h> +#include <math.h> +#include "dec2oct.h" +#include <stdio.h> + +void i16dec2octs(int16 in,int16* out) +{ + int i=0,j=0,tmp=0; + int quotient; + quotient=(int)in; + while(quotient!=0) + { + out[i++]= quotient%8; + quotient=quotient/8; + } + j=i-1; + i=0; + + while(i<j) + { + tmp=out[i]; + out[i]=out[j]; + out[j]=tmp; + i++; + j--; + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/i8dec2octa.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/i8dec2octa.c new file mode 100644 index 00000000..221f486b --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/i8dec2octa.c @@ -0,0 +1,9 @@ +#include "dec2oct.h" + +void i8dec2octa(int8* in,int size,int8* out) +{ + int i=0; + for(i=0;i<size;i++) + { i8dec2octs(in[i],&(out[i*15])); +} +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/i8dec2octs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/i8dec2octs.c new file mode 100644 index 00000000..30ae5b02 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/i8dec2octs.c @@ -0,0 +1,27 @@ +#include <string.h> +#include <math.h> +#include "dec2oct.h" +#include <stdio.h> + +void i8dec2octs(int8 in,int8* out) +{ + int i=0,j=0,tmp=0; + int quotient; + quotient=(int)in; + while(quotient!=0) + { + out[i++]= quotient%8; + quotient=quotient/8; + } + j=i-1; + i=0; + + while(i<j) + { + tmp=out[i]; + out[i]=out[j]; + out[j]=tmp; + i++; + j--; + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/u16dec2octa.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/u16dec2octa.c new file mode 100644 index 00000000..cc0d5434 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/u16dec2octa.c @@ -0,0 +1,9 @@ +#include "dec2oct.h" + +void u16dec2octa(uint16* in,int size,uint16* out) +{ + int i=0; + for(i=0;i<size;i++) + { u16dec2octs(in[i],&(out[i*15])); +} +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/u16dec2octs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/u16dec2octs.c new file mode 100644 index 00000000..4b0bd592 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/u16dec2octs.c @@ -0,0 +1,27 @@ +#include <string.h> +#include <math.h> +#include "dec2oct.h" +#include <stdio.h> + +void u16dec2octs(uint16 in,uint16* out) +{ + int i=0,j=0,tmp=0; + int quotient; + quotient=(int)in; + while(quotient!=0) + { + out[i++]= quotient%8; + quotient=quotient/8; + } + j=i-1; + i=0; + + while(i<j) + { + tmp=out[i]; + out[i]=out[j]; + out[j]=tmp; + i++; + j--; + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/u8dec2octa.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/u8dec2octa.c new file mode 100644 index 00000000..c187077c --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/u8dec2octa.c @@ -0,0 +1,9 @@ +#include "dec2oct.h" + +void u8dec2octa(uint8* in,int size,uint8* out) +{ + int i=0; + for(i=0;i<size;i++) + { u8dec2octs(in[i],&(out[i*15])); +} +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/u8dec2octs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/u8dec2octs.c new file mode 100644 index 00000000..9348630f --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/dec2oct/u8dec2octs.c @@ -0,0 +1,27 @@ +#include <string.h> +#include <math.h> +#include "dec2oct.h" +#include <stdio.h> + +void u8dec2octs(uint8 in,uint8* out) +{ + int i=0,j=0,tmp=0; + int quotient; + quotient=(int)in; + while(quotient!=0) + { + out[i++]= quotient%8; + quotient=quotient/8; + } + j=i-1; + i=0; + + while(i<j) + { + tmp=out[i]; + out[i]=out[j]; + out[j]=tmp; + i++; + j--; + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/hex2dec/dhex2decs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/hex2dec/dhex2decs.c new file mode 100644 index 00000000..cfe05945 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/hex2dec/dhex2decs.c @@ -0,0 +1,21 @@ +#include <string.h> +#include "hex2dec.h" +#include <stdio.h> +#include <math.h> + +double dhex2decs(double in) +{ + int n=0,rem=0, base=1; + double out=0.0; + n=(int)in; + while (n!=0) + { + rem = n%10; + out = out + (rem * base); + n = n / 10 ; + base = base * 16; + } + return out; +} + + 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; + } diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/doct2deca.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/doct2deca.c new file mode 100644 index 00000000..6bb5d00f --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/doct2deca.c @@ -0,0 +1,10 @@ +#include "oct2dec.h" + +void doct2deca(double* in,int size,double* out) +{ + int i=0; + for(i=0;i<size;i++) + { + out[i]=doct2decs(in[i]); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/doct2decs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/doct2decs.c new file mode 100644 index 00000000..8f9f0b65 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/doct2decs.c @@ -0,0 +1,21 @@ +#include <string.h> +#include "oct2dec.h" +#include <stdio.h> +#include <math.h> + +double doct2decs(double in) +{ + int n=0,rem=0, base=1; + double out=0.0; + n=(int)in; + while (n!=0) + { + rem = n%10; + out = out + (rem * base); + n = n / 10 ; + base = base * 8; + } + return out; +} + + diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/i16oct2deca.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/i16oct2deca.c new file mode 100644 index 00000000..1ab843f8 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/i16oct2deca.c @@ -0,0 +1,10 @@ +#include "oct2dec.h" + +void i16oct2deca(int16* in,int size,int16* out) +{ + int i=0; + for(i=0;i<size;i++) + { + out[i]=i16oct2decs(in[i]); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/i16oct2decs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/i16oct2decs.c new file mode 100644 index 00000000..ea092852 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/i16oct2decs.c @@ -0,0 +1,21 @@ +#include <string.h> +#include "oct2dec.h" +#include <stdio.h> +#include <math.h> + +int16 i16oct2decs(int16 in) /* Function to convert octal to decimal */ +{ + int n=0,rem=0, base=1; + int16 out=0; + n=(int)in; + while (n!=0) + { + rem = n%10; + out = out + (rem * base); + n = n / 10 ; + base = base * 8; + } + return out; +} + + diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/i8oct2deca.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/i8oct2deca.c new file mode 100644 index 00000000..133806ce --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/i8oct2deca.c @@ -0,0 +1,10 @@ +#include "oct2dec.h" + +void i8oct2deca(int8* in,int size,int8* out) +{ + int i=0; + for(i=0;i<size;i++) + { + out[i]=i8oct2decs(in[i]); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/i8oct2decs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/i8oct2decs.c new file mode 100644 index 00000000..1886739a --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/i8oct2decs.c @@ -0,0 +1,21 @@ +#include <string.h> +#include "oct2dec.h" +#include <stdio.h> +#include <math.h> + +int8 i8oct2decs(int8 in) /* Function to convert octal to decimal */ +{ + int n=0,rem=0, base=1; + int8 out=0; + n=(int)in; + while (n!=0) + { + rem = n%10; + out = out + (rem * base); + n = n / 10 ; + base = base * 8; + } + return out; +} + + diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/u16oct2deca.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/u16oct2deca.c new file mode 100644 index 00000000..cec3a219 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/u16oct2deca.c @@ -0,0 +1,10 @@ +#include "oct2dec.h" + +void u16oct2deca(uint16* in,int size,uint16* out) +{ + int i=0; + for(i=0;i<size;i++) + { + out[i]=u16oct2decs(in[i]); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/u16oct2decs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/u16oct2decs.c new file mode 100644 index 00000000..43dd0ac0 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/u16oct2decs.c @@ -0,0 +1,21 @@ +#include <string.h> +#include "oct2dec.h" +#include <stdio.h> +#include <math.h> + +uint16 u16oct2decs(uint16 in) /* Function to convert octal to decimal */ +{ + int n=0,rem=0, base=1; + uint16 out=0; + n=(int)in; + while (n!=0) + { + rem = n%10; + out = out + (rem * base); + n = n / 10 ; + base = base * 8; + } + return out; +} + + diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/u8oct2deca.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/u8oct2deca.c new file mode 100644 index 00000000..3b356587 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/u8oct2deca.c @@ -0,0 +1,10 @@ +#include "oct2dec.h" + +void u8oct2deca(uint8* in,int size,uint8* out) +{ + int i=0; + for(i=0;i<size;i++) + { + out[i]=u8oct2decs(in[i]); + } +} diff --git a/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/u8oct2decs.c b/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/u8oct2decs.c new file mode 100644 index 00000000..c854bc25 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/radix_conversions/oct2dec/u8oct2decs.c @@ -0,0 +1,21 @@ +#include <string.h> +#include "oct2dec.h" +#include <stdio.h> +#include <math.h> + +uint8 u8oct2decs(uint8 in) /* Function to convert octal to decimal */ +{ + int n=0,rem=0, base=1; + uint8 out=0; + n=(int)in; + while (n!=0) + { + rem = n%10; + out = out + (rem * base); + n = n / 10 ; + base = base * 8; + } + return out; +} + + |