note 12462 deleted from function.sprintf by felipe

From: Date: Sat, 29 Dec 2007 20:42:16 +0000
Subject: note 12462 deleted from function.sprintf by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134209@lists.php.net to get a copy of this message
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

« previous php.notes (#134209) next »