[PHP-DEV] RC5 hexdec not compatible

2001-12-04 Thread chrism

?php /* hexdec.php */

/* 4.1.0 branch hexdec not compatible
 * with earlier PHP releases.
 */

/*

% php4.0.0 -f hexdec.php
lemon = 5d08374e = 1560819534
pineapple = a7e9b7d0 = -1477855280
fruit = c10d50e3 = -1056091933
sausage = 42d08254 = 1120961108
breakfast = f7d7b86e = -136857490
coconut = 1138ca81 = 288934529

% php4.0.6 -f hexdec.php
lemon = 5d08374e = 1560819534
pineapple = a7e9b7d0 = -1477855280
fruit = c10d50e3 = -1056091933
sausage = 42d08254 = 1120961108
breakfast = f7d7b86e = -136857490
coconut = 1138ca81 = 288934529

% php4.1.0RC5 -f hexdec.php
lemon = 5d08374e = 1560819534
pineapple = a7e9b7d0 = 2817112016
fruit = c10d50e3 = 3238875363
sausage = 42d08254 = 1120961108
breakfast = f7d7b86e = 4158109806
coconut = 1138ca81 = 288934529

*/

$wordlist = array(lemon, pineapple, fruit, sausage,
  breakfast,coconut);

foreach($wordlist as $word) {
$crc = mhash(MHASH_CRC32, $word);
$hex = bin2hex($crc);
$dec = hexdec($hex);
echo $word .  =  . $hex .  =  . $dec . \n;
}

?

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] RC5 hexdec not compatible

2001-12-04 Thread Thies C. Arntzen

hi,

the current behavious is more connect than the old one. 
we automagiacally propagate from in to float in the conversion
routines once we gent an overflow. to get the old bahaviour
in your case you need to case the result of hexdec() to int:

$dec = (int) hexdec($hex);

and you'll get the old behaviour back. i do think that
normally you don't want negative results from hexdec() so the
new behaviour is more correct.

re,
tc

On Tue, Dec 04, 2001 at 09:01:02AM -0500, chrism wrote:
 ?php /* hexdec.php */
 
 /* 4.1.0 branch hexdec not compatible
  * with earlier PHP releases.
  */
 
 /*
 
 % php4.0.0 -f hexdec.php
 lemon = 5d08374e = 1560819534
 pineapple = a7e9b7d0 = -1477855280
 fruit = c10d50e3 = -1056091933
 sausage = 42d08254 = 1120961108
 breakfast = f7d7b86e = -136857490
 coconut = 1138ca81 = 288934529
 
 % php4.0.6 -f hexdec.php
 lemon = 5d08374e = 1560819534
 pineapple = a7e9b7d0 = -1477855280
 fruit = c10d50e3 = -1056091933
 sausage = 42d08254 = 1120961108
 breakfast = f7d7b86e = -136857490
 coconut = 1138ca81 = 288934529
 
 % php4.1.0RC5 -f hexdec.php
 lemon = 5d08374e = 1560819534
 pineapple = a7e9b7d0 = 2817112016
 fruit = c10d50e3 = 3238875363
 sausage = 42d08254 = 1120961108
 breakfast = f7d7b86e = 4158109806
 coconut = 1138ca81 = 288934529
 
 */
 
 $wordlist = array(lemon, pineapple, fruit, sausage,
 breakfast,coconut);
 
 foreach($wordlist as $word) {
   $crc = mhash(MHASH_CRC32, $word);
   $hex = bin2hex($crc);
   $dec = hexdec($hex);
   echo $word .  =  . $hex .  =  . $dec . \n;
 }
 
 ?
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]