Hello,

This is a reply to an e-mail that you wrote on Mon, 14 Jul 2003 at 09:00,
lines prefixed by '>' were originally written by you.
> A bit off topic
> Im trying to figure out how to convert BigEndian byte words to
> integers.
> For example ->
> 0 0 0 18  =  18
> The only way I know how to convert this is by writing down on paper,
> and
> writing  8 4 2 1 above the numbers and adding up the values.

Never heard of a BigEndian number beofre, but this should do it...

function BigEndiantoInt($bigendian){
    $bits = split(" ",$bigendian);
    $bits = array_reverse($bits);
    $value = 0; $columnvalue = 1;
    foreach($bits as $thisbit){
        $value = $value + ($columnvalue * $thisbit);
        $columnvalue = $columnvalue * 2;
    }
    return $value;
}

HTH

David

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

          Professional Web Development by David Nicholson
                    http://www.djnicholson.com/

    QuizSender.com - How well do your friends actually know you?
                     http://www.quizsender.com/
                    (developed entirely in PHP)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to