School-HTML/3AIN/Convertitore Decimale Binar.../decToBinary.html

24 lines
972 B
HTML

<!DOCTYPE html>
<html lang="it">
<head>
<!-- Supporto dispositivi mobili -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Conversione Decimale in Binario</title>
<link rel="stylesheet" href="res/style.css">
</head>
<body>
<h1>Convertitore Decimale in Binario</h1>
<label for="numero">Inserisci un numero decimale (da -128 a 255):</label>
<input type="number" id="numero" placeholder="Numero decimale" required>
<br>
<label for="complemento2">Usa Complemento a 2 (per numeri negativi):</label>
<input type="checkbox" id="complemento2">
<br>
<button onclick="convertiBinario(document.getElementById('numero').value, document.getElementById('complemento2').checked, document.getElementById('binario'))">Converti in Binario</button>
<h2>Risultato Binario (8 bit):</h2>
<div id="binario">00000000</div>
<script src="res/script.js"></script>
</body>
</html>