-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathch2.html
More file actions
126 lines (120 loc) · 4.05 KB
/
Copy pathch2.html
File metadata and controls
126 lines (120 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<!DOCTYPE html>
<html>
<head>
<title>CS319 Practices - Binary Number System</title>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META name="description" content="Practice Tools for Internal Data Representation Concepts in Computer Architecture Course">
<META name="keywords" content="binary number system, data representation, practice tool, Computer Architecture, Computer Organization">
<META http-equiv="Cache-Control" content="no-cache">
<link rel="stylesheet" href="assets/css/stylesp.css">
</head>
<body>
<ul class="breadcrumb">
<li><a href=".">Home</a></li>
<li>Binary Number System</li>
</ul>
<h2>Binary Number System</h2>
<p>This section practices the basics of converting between binary and decimal. </p>
<p>How to use an exercise:</p>
<ul>
<li>Follow steps 1-2-3-4, but you may use the "Start" button of an exercise at any time to restart.</li>
<li>Looking for examples of how to solve a problem? Just click "Start" in step 1, type something for step 2, and move to the step-by-step solution in step 4.</li>
</ul>
<h4>Exercise 1. Convert Binary to Decimal</h4>
<table>
<tr>
<td>1. Generate a random binary number: </td>
<td><button id="p1StartBtn" type="button" onclick="p1Random0ToN()">Start</button></td>
<td><p id="p1Data"></p></td>
</tr>
<tr>
<td>2. Please convert it to decimal:</td>
<td>-</td>
<td><input id="p1Input"></td>
</tr>
<tr>
<td>3. Now check your answer:</td>
<td><button id="p1CheckBtn" type="button" onclick="p1CheckResult()" disabled="true">Check</button></td>
<td><p id="p1Result">-</p></td>
</tr>
<tr>
<td>4. Show the solution:</td>
<td><button id="p1AnswerBtn" type="button" onclick="p1ShowAnswer()" disabled="true">Solution</button></td>
<td><p id="p1Answer">-</p></td>
</tr>
</table>
<h4>Exercise 2. Convert Decimal to Binary - integer</h4>
<table>
<tr>
<td>1. Generate a random decimal number: </td>
<td><button id="p2StartBtn" type="button" onclick="p2Random0ToN()">Start</button></td>
<td><p id="p2Data"></p></td>
</tr>
<tr>
<td>2. Please convert it to binary:</td>
<td>-</td>
<td><input id="p2Input"></td>
</tr>
<tr>
<td>3. Now check your answer:</td>
<td><button id="p2CheckBtn" type="button" onclick="p2CheckResult()" disabled="true">Check</button></td>
<td><p id="p2Result">-</p></td>
</tr>
<tr>
<td>4. Show the solution:</td>
<td><button id="p2AnswerBtn" type="button" onclick="p2ShowAnswer()" disabled="true">Solution</button></td>
<td><p id="p2Answer">-</p></td>
</tr>
</table>
<h4>Exercise 3. Convert Decimal to Binary - fraction</h4>
<table>
<tr>
<td>1. Generate a random decimal fraction: </td>
<td><button id="p3StartBtn" type="button" onclick="p3Random0ToN()">Start</button></td>
<td><p id="p3Data"></p></td>
</tr>
<tr>
<td>2. Please convert it to binary (At most 6 bits <br/>after the binary point. Drop additional bits. <br/>Do not round up.):</td>
<td>-</td>
<td><input id="p3Input"> (write it as 0.xxxx)</td>
</tr>
<tr>
<td>3. Now check your answer:</td>
<td><button id="p3CheckBtn" type="button" onclick="p3CheckResult()" disabled="true">Check</button></td>
<td><p id="p3Result">-</p></td>
</tr>
<tr>
<td>4. Show the solution:</td>
<td><button id="p3AnswerBtn" type="button" onclick="p3ShowAnswer()" disabled="true">Solution</button></td>
<td><p id="p3Answer">-</p></td>
</tr>
</table>
<script src = "js/ch2work.js"></script>
<h2> </h2>
<p>
<b>© 2022
Bin Peng</b><br>
Bug reports and comments are welcome: crystal dot peng at park dot edu<br><br>
Last Update:
<script type="text/javascript">
var month=new Array(12);
month[0]="January";
month[1]="February";
month[2]="March";
month[3]="April";
month[4]="May";
month[5]="June";
month[6]="July";
month[7]="August";
month[8]="September";
month[9]="October";
month[10]="November";
month[11]="December";
moddate=new Date(document.lastModified); //convert to local time
document.write(month[moddate.getMonth()]+" "+ moddate.getDate()+", "+ moddate.getFullYear());
</script>
<br>
Created: January 17, 2018
</p>
</body>
</html>