Php > Miscellaneous
Binary Conversion
Binary Conversion Please only choose numbers smaller than 255
Convert this number:
FORM;} } elseif($_GET['t'] == "b2") { if($Submit2) { if($num1 == 1) { $number = 128; } if($num2 == 1) { $number += 64; } if($num3 == 1) { $number += 32; } if($num4 == 1) { $number += 16; } if($num5 == 1) { $number += 8; } if($num6 == 1) { $number += 4; } if($num7 == 1) { $number += 2; } if($num8 == 1) { $number += 1; } echo "
The converted number is: $number
"; } else{ echo <<
Place the number "1" or "0" in the boxes
FORM;} } else { echo <<
Binary Conversions
Decimal to Binary:
Binary to Decimal:
FORM;} function makeBinary($x) { if(($x - 128) >= 0) { $binary = '1'; $x = $x - 128; } else { $binary = '0'; } if(($x - 64) >= 0) { $binary = "$binary 1"; $x = $x - 64; } else { $binary = "$binary 0"; } if(($x - 32) >= 0) { $binary = "$binary 1"; $x = $x - 32; } else { $binary = "$binary 0"; } if(($x - 16) >= 0) { $binary = "$binary 1"; $x = $x - 16; } else { $binary = "$binary 0"; } if(($x - 8) >= 0) { $binary = "$binary 1"; $x = $x - 8; } else { $binary = "$binary 0"; } if(($x - 4) >= 0) { $binary = "$binary 1"; $x = $x - 4; } else { $binary = "$binary 0"; } if(($x - 2) >= 0) { $binary = "$binary 1"; $x = $x - 2; } else { $binary = "$binary 0"; } if(($x - 1) >= 0) { $binary = "$binary 1"; $x = $x; echo "
$binary
"; } else { $binary = "$binary 0"; echo "
$binary
"; } } ?>
Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage