-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecimal.html
More file actions
95 lines (91 loc) · 3.77 KB
/
decimal.html
File metadata and controls
95 lines (91 loc) · 3.77 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>IEEE-754 Decimal-32 Floating-Point Converter</title>
<link rel="stylesheet" href="layout/styles.css">
<style>
.output-boxes {
display: none; /* Hide the output boxes initially */
}
.output-boxes.show {
display: block; /* Show the output boxes when results are available */
}
</style>
</head>
<body>
<header>
<h1>IEEE-754 Decimal-32 floating-point <span>converter</span></h1>
</header>
<div class="container-decimal">
<div class="container-title-decimal">
Enter decimal:
</div>
<div class="converter-box">
<form id="converter-form">
<div class="input-group">
<input type="text" id="baseNumber" class="decimal-input" required>
<span>x 10^</span>
<input type="text" id="exponent" class="exponent-input" required>
</div>
<div class="round-off-group">
<label class="round-off-label" for="round-off-method">Round-off method:</label>
<select id="round-off-method">
<option value="truncate">Truncate</option>
<option value="round down">Round down</option>
<option value="round up">Round up</option>
</select>
</div>
<button type="submit" class="convert-button">Convert</button>
</form>
</div>
<!-- Output fields -->
<div class="output-boxes" id="output-boxes">
<div class="output-box">
<h2>Decimal</h2>
<p id="decimal-output">[Decimal output will be displayed here]</p>
</div>
<div class="output-box">
<h2>Binary (32-bit)</h2>
<p id="binary-output">[Binary output will be displayed here]</p>
</div>
<div class="output-box">
<h2>Hexadecimal (32-bit)</h2>
<p id="hex-output">[Hexadecimal output will be displayed here]</p>
</div>
<div class="output-box">
<h2>Normalized</h2>
<p id="normalized-output">[Normalized output will be displayed here]</p>
</div>
</div>
</div>
<footer>
<p>By GROUP 14: Calugtong, Salic, Valladolid</p>
</footer>
<script src="ieee754-converter.js"></script>
<script>
document.getElementById('converter-form').addEventListener('submit', function(event) {
event.preventDefault();
convert();
});
function convert() {
var baseNumber = parseFloat(document.getElementById('baseNumber').value);
var exponent = parseInt(document.getElementById('exponent').value, 10);
var number = baseNumber * Math.pow(10, exponent);
var ieee754 = new extIeee754();
var decimalOutput = ieee754.to('dec', number);
var binaryOutput = ieee754.to('bin32', number);
var hexOutput = ieee754.to('hex32', number);
var normalizedOutput = ieee754.normalize(number);
// Save results to localStorage
localStorage.setItem('decimal', decimalOutput);
localStorage.setItem('binary', binaryOutput);
localStorage.setItem('hexadecimal', hexOutput);
localStorage.setItem('normalized', normalizedOutput);
// Redirect to output.html
window.location.href = 'output.html';
}
</script>
</body>
</html>