note 32521 added to function.bindec

From: Date: Fri, 30 May 2003 03:47:23 +0000
Subject: note 32521 added to function.bindec
Groups: php.notes 
Request: Send a blank email to php-notes+get-49389@lists.php.net to get a copy of this message
## calculate binary with "shift-method" ## function dec2bin($decimal_code){ for($half=($decimal_code);$half>=1;$half=(floor($half))/2){ if(($half%2)!=0){ $y.=1; } else{ $y.=0; } } $calculated_bin=strrev($y); return $calculated_bin; } ## example ## [bin] 123 = [dec] 1111011 e.g. 123/2 = 61,5 => 1 61/2 = 30,5 => 1 30/2 = 15 => 0 15/2 = 7,5 => 1 7/2 = 3,5 => 1 3/2 = 1,5 => 1 1/2 = 0,5 => 1 (0/2 = 0 finish) ---- Manual Page -- http://www.php.net/manual/en/function.bindec.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32521 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32521&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32521&report=yes

« previous php.notes (#49389) next »