base_convert():Converting from one base to other

string base_convert(string $number, int $from_base, int $to_base);
ParameterDESCRIPTION
$numberRequired : Input string representing number to convert. With a base higher than 10 is represented by Char.
Here a is 10, b is 11 ... so z is 35. ( case in-sensitive )
$from_baseRequired : ( between 2 and 36 , inclusive )
$to_baseRequired : ( between 2 and 36 , inclusive )
The output is number converted to $to_base base.

Example : Decimal to Decimal to Binary

echo base_convert(6,10,2); // Output 110 
echo "<br>";
echo base_convert(42,10,2); // Output 101010 

Example : Decimal to Octal

echo base_convert(10,10,8); // Output is 12
echo "<br>";
echo base_convert('15',10,8); // Output is 17

Example : Decimal to Hex

echo base_convert(12,10,16); // Output is c
echo "<br>";
echo base_convert('25',10,16); // Output is 19

Example : Octal to Binary

echo base_convert(13,8,2); // Output is 1011
echo "<br>";
echo base_convert('25',8,2); // Output is 10101

Example Octal to Decimal

echo base_convert(14,8,10); // Output is 12
echo "<br>";
echo base_convert(27,8,10); // Output is 23

Example Octal to Hex

echo base_convert(15,8,16); // Output is d
echo "<br>";
echo base_convert(30,8,16); // Output is 18

Example Hex to Binary

echo base_convert(15,16,2); // Output is 10101
echo "<br>";
echo base_convert(31,16,2); // Output is 110001

Example Hex to Octal

echo base_convert(14,16,8); // Output is 24
echo "<br>";
echo base_convert(32,16,8); // Output is 62

Example Hex to Decimal

echo base_convert(13,16,10); // Output is 19
echo "<br>";
echo base_convert(33,16,10); // Output is 51


plus2net.com




Post your comments , suggestion , error , requirements etc here .




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer