[PHP] Workaround for binary arithmatic

2001-07-31 Thread Richard Ellerbrock

I am looking for a php only workaround to do binary arithmatic on large numbers (ip 
addresses represented as integer). Works fine for small numbers (smaller than signed 
long), but ip addresses are unsigned long.

The following yeilds incorrect results:

echo 2473474821  4;

The correct answer is NOT 0;

I now have to call an external perl program to do the calc. I have a bug logged with 
php development, but the answer I got is that this will not work till you can have 
unsigned longs in php. I am using php 4.0.6

Please copy me on replies. TIA


--
Richard Ellerbrock
[EMAIL PROTECTED]


--
PHP General 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] Workaround for binary arithmatic

2001-07-31 Thread Phil Driscoll

Use the gmp extension.
-- 
Phil Driscoll

-- 
PHP General 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] Workaround for binary arithmatic

2001-07-31 Thread Richard Ellerbrock

I thought about that but that would require almost everybody using my app (OpenSource) 
requiring a rebuild of php. This would really detract from its usefulness.

--
Richard Ellerbrock
[EMAIL PROTECTED]

 Phil Driscoll [EMAIL PROTECTED] 2001/07/31 04:02:50 
Use the gmp extension.
-- 
Phil Driscoll


--
PHP General 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] Workaround for binary arithmatic

2001-07-31 Thread Phil Driscoll

On Tuesday 31 July 2001 15:26, Richard Ellerbrock wrote:
 I thought about that but that would require almost everybody using my app
 (OpenSource) requiring a rebuild of php. This would really detract from its
 usefulness.

 --
 Richard Ellerbrock
 [EMAIL PROTECTED]

  Phil Driscoll [EMAIL PROTECTED] 2001/07/31 04:02:50 

 Use the gmp extension.
Ok - then the only other solution I could think of (and for me it was easier 
just to build php with gmp) was to split all your integers up into 16 bit 
chunks and do the maths longhand on the 16 bit integers. That way, you'll 
avoid the top bit set problem.

Cheers
-- 
Phil Driscoll

-- 
PHP General 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]