summaryrefslogtreecommitdiff
path: root/45/CH5/EX5.10/example_5_10.sce
blob: 7ce381e52c896102cef46c741f49698eef15073c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//Example 5.10
clc                                     //clears the command window
clear                                    //clears the variables 
q=0;
b=0;
//a=input("enter the decimal no:")
a=56000;                                    // giving the value specified in the problem
temp=a; 
format('v',18)                              //increasing the precision to 18
a=floor(a);
h=dec2hex(a);
while(a>0)                                   // converting to binary 
    x=modulo(a,2);
    b= b + (10^q)*x;
    a=a/2;
    a=floor(a);
    q=q+1; 
end
printf("Given decimal number is : %d\n",temp)
printf("The hexadecimal equivalent is = %s\n",h)
  //displaying the results 
printf("The binary equivalent is = %f\n",b);