<?php
if (isset($_POST['decimal'])) {
$des = $_POST['decimal'];
$original = $_POST['decimal'];
$oct ='';
if (preg_match('/[^0-9]/',$des)){
die("Maaf. Inputan salah..");
}
else {
while($des>0){
$hasil=$des%8;
switch($hasil){
case 0: $oct.="0"; break;
case 1: $oct.="1"; break;
case 2: $oct.="2"; break;
case 3: $oct.="3"; break;
case 4: $oct.="4"; break;
case 5: $oct.="5"; break;
case 6: $oct.="6"; break;
case 7: $oct.="7"; break;
case 8: $oct.="10"; break;
case 9: $oct.="11"; break;
case 10: $oct.="12"; break;
case 11: $oct.="13"; break;
case 12: $oct.="14"; break;
case 13: $oct.="15"; break;
case 14: $oct.="16"; break;
case 15: $oct.="17";
default:break;
}
Jumat, 10 Agustus 2012
Script Decimal To Hexa for PHP
<?php
if (isset($_POST['decimal'])) {
$des = $_POST['decimal'];
$original = $_POST['decimal'];
$hexa ='';
if (preg_match('/[^0-9]/',$des)){
die("Maaf. Inputan salah..");
}
else {
while($des>0){
$hasil=$des%16;
switch($hasil){
case 0: $hexa.="0"; break;
case 1: $hexa.="1"; break;
case 2: $hexa.="2"; break;
case 3: $hexa.="3"; break;
case 4: $hexa.="4"; break;
case 5: $hexa.="5"; break;
case 6: $hexa.="6"; break;
case 7: $hexa.="7"; break;
case 8: $hexa.="8"; break;
case 9: $hexa.="9"; break;
case 10: $hexa.="A"; break;
case 11: $hexa.="B"; break;
case 12: $hexa.="C"; break;
case 13: $hexa.="D"; break;
case 14: $hexa.="E"; break;
case 15: $hexa.="F";
default:break;
}
if (isset($_POST['decimal'])) {
$des = $_POST['decimal'];
$original = $_POST['decimal'];
$hexa ='';
if (preg_match('/[^0-9]/',$des)){
die("Maaf. Inputan salah..");
}
else {
while($des>0){
$hasil=$des%16;
switch($hasil){
case 0: $hexa.="0"; break;
case 1: $hexa.="1"; break;
case 2: $hexa.="2"; break;
case 3: $hexa.="3"; break;
case 4: $hexa.="4"; break;
case 5: $hexa.="5"; break;
case 6: $hexa.="6"; break;
case 7: $hexa.="7"; break;
case 8: $hexa.="8"; break;
case 9: $hexa.="9"; break;
case 10: $hexa.="A"; break;
case 11: $hexa.="B"; break;
case 12: $hexa.="C"; break;
case 13: $hexa.="D"; break;
case 14: $hexa.="E"; break;
case 15: $hexa.="F";
default:break;
}
Langganan:
Postingan (Atom)
About
listen !
dengan mendengar, suatu perasaan akan terbit dari fikiran, yang akan membawa sebuah keinginan untuk selalu ingin tahu apa yang belum di ketahui. pengetahuan itu luas, jangan kau berhenti sebelum mengenal dan menggenggam dunia di telapak tangan mu !