I sent this about a week ago, but I forgot to 'reply to all', and send
it to the list.
Thanks Rolf for pointing that out to me.
I'm not totally sure, but this might work. I'm too tired to understand
rolf's masks, but:
?php
function bin2int($bin){
$a = bindec($bin);
return ($a 128) ? ($a) :
Just a couple of comments about those 0x.. and 11
in my post.
(By the way, i haven't looked to closely on speed even if the OP asked
for that, i was unsure on how he was coding his numbers).
[EMAIL PROTECTED] (Rolf Østvik) wrote in
news:[EMAIL PROTECTED]:
[EMAIL PROTECTED] (René
René Fournier wrote:
I've looked in the docs and don't see anything for this per se...
I need to convert a binary number of arbitrary length to a signed integer.
This is how I'm doing it now:
CODE
function bin2int ($bin) {
if (substr($bin,0,1) == 1) {
$val = 0 -
Well that was retarded of me... I missed that you said you needed
negative integers... in which case I don't know of anything better than
what you've already coded.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[EMAIL PROTECTED] (René Fournier) wrote in
news:[EMAIL PROTECTED]:
I need to convert a binary number of arbitrary length to a signed
integer.
This is how I'm doing it now:
CODE
function bin2int ($bin) {
if (substr($bin,0,1) == 1) {
$val = 0 -
5 matches
Mail list logo