diff options
author | Sandeep Gupta | 2017-06-18 23:55:40 +0530 |
---|---|---|
committer | Sandeep Gupta | 2017-06-18 23:55:40 +0530 |
commit | 277d1edfa17bf3719d90ddbac8e31f6181e952c3 (patch) | |
tree | 0661f1f52af0a0fd654edd4984c30e57037303c6 /src/c/elementaryFunctions/radix_conversions | |
download | Scilab2C_fossee_old-277d1edfa17bf3719d90ddbac8e31f6181e952c3.tar.gz Scilab2C_fossee_old-277d1edfa17bf3719d90ddbac8e31f6181e952c3.tar.bz2 Scilab2C_fossee_old-277d1edfa17bf3719d90ddbac8e31f6181e952c3.zip |
First commit
Diffstat (limited to 'src/c/elementaryFunctions/radix_conversions')
58 files changed, 1975 insertions, 0 deletions
diff --git a/src/c/elementaryFunctions/radix_conversions/base2dec/dbase2decs.c b/src/c/elementaryFunctions/radix_conversions/base2dec/dbase2decs.c new file mode 100644 index 0000000..a92fc76 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/base2dec/dbase2decs.c @@ -0,0 +1,32 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/base2dec/gbase2decs.c b/src/c/elementaryFunctions/radix_conversions/base2dec/gbase2decs.c new file mode 100644 index 0000000..811a411 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/base2dec/gbase2decs.c @@ -0,0 +1,166 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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 * (int)pow((double)base, size)); + size--; + } + return o; + } diff --git a/src/c/elementaryFunctions/radix_conversions/bin2dec/dbin2deca.c b/src/c/elementaryFunctions/radix_conversions/bin2dec/dbin2deca.c new file mode 100644 index 0000000..96fccc5 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/bin2dec/dbin2deca.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/bin2dec/dbin2decs.c b/src/c/elementaryFunctions/radix_conversions/bin2dec/dbin2decs.c new file mode 100644 index 0000000..ff363c3 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/bin2dec/dbin2decs.c @@ -0,0 +1,32 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/bin2dec/i16bin2deca.c b/src/c/elementaryFunctions/radix_conversions/bin2dec/i16bin2deca.c new file mode 100644 index 0000000..8511df9 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/bin2dec/i16bin2deca.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/bin2dec/i16bin2decs.c b/src/c/elementaryFunctions/radix_conversions/bin2dec/i16bin2decs.c new file mode 100644 index 0000000..9aa3be9 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/bin2dec/i16bin2decs.c @@ -0,0 +1,32 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/bin2dec/i8bin2deca.c b/src/c/elementaryFunctions/radix_conversions/bin2dec/i8bin2deca.c new file mode 100644 index 0000000..c923ffb --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/bin2dec/i8bin2deca.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/bin2dec/i8bin2decs.c b/src/c/elementaryFunctions/radix_conversions/bin2dec/i8bin2decs.c new file mode 100644 index 0000000..abd3b89 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/bin2dec/i8bin2decs.c @@ -0,0 +1,32 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/bin2dec/u16bin2deca.c b/src/c/elementaryFunctions/radix_conversions/bin2dec/u16bin2deca.c new file mode 100644 index 0000000..b6b75d7 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/bin2dec/u16bin2deca.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/bin2dec/u16bin2decs.c b/src/c/elementaryFunctions/radix_conversions/bin2dec/u16bin2decs.c new file mode 100644 index 0000000..cb45a20 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/bin2dec/u16bin2decs.c @@ -0,0 +1,32 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/bin2dec/u8bin2deca.c b/src/c/elementaryFunctions/radix_conversions/bin2dec/u8bin2deca.c new file mode 100644 index 0000000..10461ca --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/bin2dec/u8bin2deca.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/bin2dec/u8bin2decs.c b/src/c/elementaryFunctions/radix_conversions/bin2dec/u8bin2decs.c new file mode 100644 index 0000000..0a0f5c4 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/bin2dec/u8bin2decs.c @@ -0,0 +1,32 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2base/ddec2basea.c b/src/c/elementaryFunctions/radix_conversions/dec2base/ddec2basea.c new file mode 100644 index 0000000..4de34f0 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2base/ddec2basea.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2base/ddec2bases.c b/src/c/elementaryFunctions/radix_conversions/dec2base/ddec2bases.c new file mode 100644 index 0000000..dae7bdc --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2base/ddec2bases.c @@ -0,0 +1,71 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2base/sdec2basea.c b/src/c/elementaryFunctions/radix_conversions/dec2base/sdec2basea.c new file mode 100644 index 0000000..dc4d859 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2base/sdec2basea.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2base/sdec2bases.c b/src/c/elementaryFunctions/radix_conversions/dec2base/sdec2bases.c new file mode 100644 index 0000000..a627c05 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2base/sdec2bases.c @@ -0,0 +1,45 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2bin/ddec2bina.c b/src/c/elementaryFunctions/radix_conversions/dec2bin/ddec2bina.c new file mode 100644 index 0000000..c69b782 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2bin/ddec2bina.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2bin/ddec2bins.c b/src/c/elementaryFunctions/radix_conversions/dec2bin/ddec2bins.c new file mode 100644 index 0000000..f5db16c --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2bin/ddec2bins.c @@ -0,0 +1,50 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2bin/i16dec2bina.c b/src/c/elementaryFunctions/radix_conversions/dec2bin/i16dec2bina.c new file mode 100644 index 0000000..93d1fdd --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2bin/i16dec2bina.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2bin/i16dec2bins.c b/src/c/elementaryFunctions/radix_conversions/dec2bin/i16dec2bins.c new file mode 100644 index 0000000..5df0fe8 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2bin/i16dec2bins.c @@ -0,0 +1,43 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2bin/i8dec2bina.c b/src/c/elementaryFunctions/radix_conversions/dec2bin/i8dec2bina.c new file mode 100644 index 0000000..90062f9 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2bin/i8dec2bina.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2bin/i8dec2bins.c b/src/c/elementaryFunctions/radix_conversions/dec2bin/i8dec2bins.c new file mode 100644 index 0000000..ea68985 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2bin/i8dec2bins.c @@ -0,0 +1,43 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2bin/u16dec2bina.c b/src/c/elementaryFunctions/radix_conversions/dec2bin/u16dec2bina.c new file mode 100644 index 0000000..165485e --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2bin/u16dec2bina.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2bin/u16dec2bins.c b/src/c/elementaryFunctions/radix_conversions/dec2bin/u16dec2bins.c new file mode 100644 index 0000000..ea99889 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2bin/u16dec2bins.c @@ -0,0 +1,43 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2bin/u8dec2bina.c b/src/c/elementaryFunctions/radix_conversions/dec2bin/u8dec2bina.c new file mode 100644 index 0000000..4ebdc63 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2bin/u8dec2bina.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2bin/u8dec2bins.c b/src/c/elementaryFunctions/radix_conversions/dec2bin/u8dec2bins.c new file mode 100644 index 0000000..af56d92 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2bin/u8dec2bins.c @@ -0,0 +1,43 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2hex/ddec2hexa.c b/src/c/elementaryFunctions/radix_conversions/dec2hex/ddec2hexa.c new file mode 100644 index 0000000..f2fda27 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2hex/ddec2hexa.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2hex/ddec2hexs.c b/src/c/elementaryFunctions/radix_conversions/dec2hex/ddec2hexs.c new file mode 100644 index 0000000..bcbb266 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2hex/ddec2hexs.c @@ -0,0 +1,50 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2hex/i16dec2hexa.c b/src/c/elementaryFunctions/radix_conversions/dec2hex/i16dec2hexa.c new file mode 100644 index 0000000..e00eec4 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2hex/i16dec2hexa.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2hex/i16dec2hexs.c b/src/c/elementaryFunctions/radix_conversions/dec2hex/i16dec2hexs.c new file mode 100644 index 0000000..f4a15ee --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2hex/i16dec2hexs.c @@ -0,0 +1,49 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2hex/i8dec2hexa.c b/src/c/elementaryFunctions/radix_conversions/dec2hex/i8dec2hexa.c new file mode 100644 index 0000000..be659d4 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2hex/i8dec2hexa.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2hex/i8dec2hexs.c b/src/c/elementaryFunctions/radix_conversions/dec2hex/i8dec2hexs.c new file mode 100644 index 0000000..290335f --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2hex/i8dec2hexs.c @@ -0,0 +1,50 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2hex/u16dec2hexa.c b/src/c/elementaryFunctions/radix_conversions/dec2hex/u16dec2hexa.c new file mode 100644 index 0000000..abfe5aa --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2hex/u16dec2hexa.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2hex/u16dec2hexs.c b/src/c/elementaryFunctions/radix_conversions/dec2hex/u16dec2hexs.c new file mode 100644 index 0000000..b7c3c98 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2hex/u16dec2hexs.c @@ -0,0 +1,49 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2hex/u8dec2hexa.c b/src/c/elementaryFunctions/radix_conversions/dec2hex/u8dec2hexa.c new file mode 100644 index 0000000..8fe0526 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2hex/u8dec2hexa.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2hex/u8dec2hexs.c b/src/c/elementaryFunctions/radix_conversions/dec2hex/u8dec2hexs.c new file mode 100644 index 0000000..acf236e --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2hex/u8dec2hexs.c @@ -0,0 +1,49 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2oct/ddec2octa.c b/src/c/elementaryFunctions/radix_conversions/dec2oct/ddec2octa.c new file mode 100644 index 0000000..f6cbcfe --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2oct/ddec2octa.c @@ -0,0 +1,20 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2oct/ddec2octs.c b/src/c/elementaryFunctions/radix_conversions/dec2oct/ddec2octs.c new file mode 100644 index 0000000..702f186 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2oct/ddec2octs.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2oct/i16dec2octa.c b/src/c/elementaryFunctions/radix_conversions/dec2oct/i16dec2octa.c new file mode 100644 index 0000000..fec152c --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2oct/i16dec2octa.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2oct/i16dec2octs.c b/src/c/elementaryFunctions/radix_conversions/dec2oct/i16dec2octs.c new file mode 100644 index 0000000..340958f --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2oct/i16dec2octs.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2oct/i8dec2octa.c b/src/c/elementaryFunctions/radix_conversions/dec2oct/i8dec2octa.c new file mode 100644 index 0000000..0c96f01 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2oct/i8dec2octa.c @@ -0,0 +1,20 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2oct/i8dec2octs.c b/src/c/elementaryFunctions/radix_conversions/dec2oct/i8dec2octs.c new file mode 100644 index 0000000..0a35f94 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2oct/i8dec2octs.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2oct/u16dec2octa.c b/src/c/elementaryFunctions/radix_conversions/dec2oct/u16dec2octa.c new file mode 100644 index 0000000..7a3e60e --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2oct/u16dec2octa.c @@ -0,0 +1,20 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2oct/u16dec2octs.c b/src/c/elementaryFunctions/radix_conversions/dec2oct/u16dec2octs.c new file mode 100644 index 0000000..99936b4 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2oct/u16dec2octs.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2oct/u8dec2octa.c b/src/c/elementaryFunctions/radix_conversions/dec2oct/u8dec2octa.c new file mode 100644 index 0000000..1a4e026 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2oct/u8dec2octa.c @@ -0,0 +1,20 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/dec2oct/u8dec2octs.c b/src/c/elementaryFunctions/radix_conversions/dec2oct/u8dec2octs.c new file mode 100644 index 0000000..fbfc104 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/dec2oct/u8dec2octs.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/hex2dec/dhex2decs.c b/src/c/elementaryFunctions/radix_conversions/hex2dec/dhex2decs.c new file mode 100644 index 0000000..4297573 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/hex2dec/dhex2decs.c @@ -0,0 +1,32 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/hex2dec/ghex2decs.c b/src/c/elementaryFunctions/radix_conversions/hex2dec/ghex2decs.c new file mode 100644 index 0000000..eb42a7a --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/hex2dec/ghex2decs.c @@ -0,0 +1,87 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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 * (int)pow((double)16, size)); + size--; + } + return o; + } diff --git a/src/c/elementaryFunctions/radix_conversions/oct2dec/doct2deca.c b/src/c/elementaryFunctions/radix_conversions/oct2dec/doct2deca.c new file mode 100644 index 0000000..e3619eb --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/oct2dec/doct2deca.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/oct2dec/doct2decs.c b/src/c/elementaryFunctions/radix_conversions/oct2dec/doct2decs.c new file mode 100644 index 0000000..b126c61 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/oct2dec/doct2decs.c @@ -0,0 +1,32 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/oct2dec/i16oct2deca.c b/src/c/elementaryFunctions/radix_conversions/oct2dec/i16oct2deca.c new file mode 100644 index 0000000..9db3e2e --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/oct2dec/i16oct2deca.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/oct2dec/i16oct2decs.c b/src/c/elementaryFunctions/radix_conversions/oct2dec/i16oct2decs.c new file mode 100644 index 0000000..928c3a2 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/oct2dec/i16oct2decs.c @@ -0,0 +1,32 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/oct2dec/i8oct2deca.c b/src/c/elementaryFunctions/radix_conversions/oct2dec/i8oct2deca.c new file mode 100644 index 0000000..de57a0e --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/oct2dec/i8oct2deca.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/oct2dec/i8oct2decs.c b/src/c/elementaryFunctions/radix_conversions/oct2dec/i8oct2decs.c new file mode 100644 index 0000000..b95a042 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/oct2dec/i8oct2decs.c @@ -0,0 +1,32 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/oct2dec/u16oct2deca.c b/src/c/elementaryFunctions/radix_conversions/oct2dec/u16oct2deca.c new file mode 100644 index 0000000..7778ee9 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/oct2dec/u16oct2deca.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/oct2dec/u16oct2decs.c b/src/c/elementaryFunctions/radix_conversions/oct2dec/u16oct2decs.c new file mode 100644 index 0000000..4b30443 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/oct2dec/u16oct2decs.c @@ -0,0 +1,32 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/oct2dec/u8oct2deca.c b/src/c/elementaryFunctions/radix_conversions/oct2dec/u8oct2deca.c new file mode 100644 index 0000000..d188020 --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/oct2dec/u8oct2deca.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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/src/c/elementaryFunctions/radix_conversions/oct2dec/u8oct2decs.c b/src/c/elementaryFunctions/radix_conversions/oct2dec/u8oct2decs.c new file mode 100644 index 0000000..f804f7f --- /dev/null +++ b/src/c/elementaryFunctions/radix_conversions/oct2dec/u8oct2decs.c @@ -0,0 +1,32 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Organization: FOSSEE, IIT Bombay + Author: Shamik Guha + Email: toolbox@scilab.in +*/ +#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; +} + + |