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/bin2dec | |
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/bin2dec')
10 files changed, 155 insertions, 0 deletions
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); +} + |