ºÝºÝߣ
Submit Search
Sumahexavector
?
0 likes
?
155 views
J
jbersosa
Follow
suma hexadecimal
Read less
Read more
1 of 2
Download now
Download to read offline
More Related Content
Sumahexavector
1.
<html> <head> <title>SUMA DE DOS
NUMEROS HEXADECIMALES</title> <?php function sumar($hexa1,$hexa2) { $arr=array(0=>'0',1=>'1',2=>'2',3=>'3',4=>'4',5=>'5',6=>'6',7 =>'7',8=>'8',9=>'9',10=>'A',11=>'B',12=>'C',13=>'D',14=>'E',15=>'F '); $hexa1=strtoupper($hexa1); $hexa2=strtoupper($hexa2); $resultado=""; $acarreo=0; $w=strlen($hexa1)-strlen($hexa2); for ($i=0;$i<$w;$i++) { $hexa2='0'.strval($hexa2); } $r=strlen($hexa2); $h1=str_split($hexa1); $h2=str_split($hexa2); foreach ($h1 as $clave=>$digito){ $i=$r-$clave-1; $digito=array_search(substr($hexa1,$i,1),$arr)+array_search(s ubstr($hexa2,$i,1),$arr)+$acarreo; if ($digito>=16){ $digito=$digito-16; $acarreo=1; } else{ $acarreo=0; } $resultado=$arr[$digito].$resultado; } if($acarreo==1){ $resultado="1".$resultado; } return $resultado; } ?> </head> <body> <h1>SUMA HEXADECIMAL</h1> <form method='post' action='<?php echo $_SERVER['PHP_SELF']?>'> <fieldset><legend>DATOS</legend> NUMERO HEXADECIMAL <input type='text' name='numero1' autofocus><br>
2.
NUMERO HEXADECIMAL <input
type='text' name='numero2'><br> <br>RESULTADO <input type='text' name='oct' readonly value='<?php echo sumar($_POST['numero1'],$_POST['numero2']); ?>'> <input type='submit' name='boton' value='enviar'> <?php if (ISSET($_POST['boton'])!=NULL) { $x=$_POST['numero1']; $y=$_POST['numero2']; echo "<br>numero 1 ".$x; echo "<br>numero 2 ".$y."<br>"; $z=sumar($_POST['numero1'],$_POST['numero2']); echo "<br>resultado".$z;} ?> </fieldset> </form> </body> </html>
Download