note 12462 deleted from function.sprintf by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: target_rex at hotmail dot com 

----

$a = 5;
// $a is a int
echo $5;
// Outputs:"5";
// If you would like to print $a as a bin,(101) like: 00000101 (8 digits)
sprintf("%8b", $a) // Witch returns exatly 00000101 (8 digits)

// My function looked like:
  //////////////////////////////////////////
  // By DrRex - www.DrRex.dk - 15/04-2001 //
  // string bin(int dec)                  //
  //////////////////////////////////////////
  function bin($dec){
    $bin = sprintf("%8b", $dec);
    return $bin;
  }
  //////////////////////////////////////////

// Very short exampels how to use bin()

  echo "\n1. 128(10) == ".bin(128)."(2)";

  $hits = 100;
  echo "\n2. Loaded ".bin($hits)."(2) times! Bib!";

// Not very usefull, nobody understands the number, exept if small counters like this one. If it wasn't 8(2) but FFFFFF(16) digits. I would give up...

// This would output:
  1. 128(10) == 10000000(2)
  2. Loaded 01100100(2) times! Bib!

-------------------------------------------------
Greetings from Christiania, Copenhagen, Denmark!
All code by DrRex
www.DrRex.dk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.