diff options
author | priyanka | 2015-06-24 15:03:17 +0530 |
---|---|---|
committer | priyanka | 2015-06-24 15:03:17 +0530 |
commit | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch) | |
tree | ab291cffc65280e58ac82470ba63fbcca7805165 /243/CH3/EX3.1 | |
download | Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2 Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip |
initial commit / add all books
Diffstat (limited to '243/CH3/EX3.1')
-rwxr-xr-x | 243/CH3/EX3.1/3_01.sce | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/243/CH3/EX3.1/3_01.sce b/243/CH3/EX3.1/3_01.sce new file mode 100755 index 000000000..0e2e7143f --- /dev/null +++ b/243/CH3/EX3.1/3_01.sce @@ -0,0 +1,22 @@ +//Example No. 3_01
+//Binary to decimal
+//Pg No. 45
+clear ;close ; clc ;
+
+b = '1101.1101'
+v = strsplit(b,'.') //splitting integral part and fraction part
+integralp = str2code(v(1))//converting strings to numbers
+fractionp = str2code(v(2))
+li = length(integralp) //lenght of integral part
+lf = length(fractionp) // and fractional part
+di = 0 ;//Initializing integral part and decimal part
+df = 0 ;
+for i = 1:li
+ di = 2*di+integralp(i)
+end
+for i = lf:-1:1
+ df = df/2 + fractionp(i)
+end
+df = df/2 ;
+d = di + df ; //Integral and fractional parts
+disp(d,'Decimal value = ')
\ No newline at end of file |