![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
27/09/2003, 08:21
|
![Avatar de Blag](http://static.forosdelweb.com/customavatars/avatar41843_1.gif) | | | Fecha de Ingreso: septiembre-2003 Ubicación: Lima
Mensajes: 68
Antigüedad: 21 años, 4 meses Puntos: 0 | |
Ahora en PHP
Código:
<?
$suma=0;$digito=0;$exponente=0;$respuesta=0;
if(isset($numero))
{
$suma = 0;
$exponente = 1;
do
{
$digito = $numero % 2;
$numero = floor($numero / 2);
$suma = $suma + $digito * $exponente;
$exponente = $exponente * 10;
}while($numero > 0);
echo "El numero binario es: $suma";
}
?>
<html>
<head><title>Prueba</title></head>
<body>
<form action="<?php print $PHP_SELF?>" method="post">
Ingrese un número decimal: <input type="text" name="numero"><br>
<input type="submit" value="Evaluar">
</form>
</body>
</html>
|