Results 1 to 2 of 2
  1. #1
    Junior Member Array
    Join Date
    Feb 2011
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Simplest way to convert binary number into a hexadecimal number !

    Most of the time you try to convert a binary number, sequence of 1 and 0 to hexadecimal. I've found the simplest, one-line, code to do it

    PHP Code:
    <?php
     
    echo dechex(bindec(1010)); 
    //output : A
    ?>
    here I convert binary to decimal and then decimal to hexadecimal using built-in fuctions.

  2. #2
    WTF Groupie Array
    Join Date
    Oct 2011
    Posts
    349
    Thanks
    0
    Thanked 2 Times in 2 Posts


    use bin2hex


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •