# Other Integers for php 6

- Thread: https://externals.io/message/21820
- Original archive: https://news-web.php.net/php.internals/21820
- Started by Ezra Nugroho on 2006-02-09T18:53:39+00:00
- Messages: 6
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #21820 — Ezra Nugroho — 2006-02-09T18:53:39+00:00

URL: https://externals.io/message/21820#21820

PHP developers,

Are the requirements for PHP 6 set in stone?

I saw in the minutes from the Paris meeting that a 64bit integer has
been proposed. I am curious if it would make sense to allow integers to
be both signed and unsigned. For me personally, I would love to have
unsigned 64bit integers.

I have a task that requires bitflag operations. Having only 16 bits to
deal with is really bad (I only care about positive int). Having 32
positive bits in PHP 6 is certainly an improvement, but if I can get all
64, then live would be much better.

http://www.php.net/~derick/meeting-notes.html#add-a-64bit-integer

Thanks,
Ezra

---

## #21821 — Rasmus Lerdorf — 2006-02-09T19:07:48+00:00

URL: https://externals.io/message/21820#21821 · In reply to: #21820

Ezra Nugroho wrote:
> PHP developers,
> 
> Are the requirements for PHP 6 set in stone?
> 
> I saw in the minutes from the Paris meeting that a 64bit integer has
> been proposed. I am curious if it would make sense to allow integers to
> be both signed and unsigned. For me personally, I would love to have
> unsigned 64bit integers.
> 
> I have a task that requires bitflag operations. Having only 16 bits to
> deal with is really bad (I only care about positive int). Having 32
> positive bits in PHP 6 is certainly an improvement, but if I can get all
> 64, then live would be much better.

Uh, positive bits?

A bitfield is a bitfield.  Signedness is irrelevant.

-Rasmus

---

## #21822 — Ezra Nugroho — 2006-02-09T19:20:11+00:00

URL: https://externals.io/message/21820#21822 · In reply to: #21821

> Uh, positive bits?

> A bitfield is a bitfield.  Signedness is irrelevant.
> 
> -Rasmus

Yes.

I probably should say integers that I can modify with bitwise operators
comfortably without changing the signs.  The problem is that people may
want to do comparison after doing bitwise operations. If the sign is
changed, the comparison will not be valid, right?

That's why I want to stay within the positive range.

---

## #21823 — Adam Maccabee Trachtenberg — 2006-02-09T19:30:38+00:00

URL: https://externals.io/message/21820#21823 · In reply to: #21820

> I have a task that requires bitflag operations. Having only 16 bits to
> deal with is really bad (I only care about positive int). Having 32
> positive bits in PHP 6 is certainly an improvement, but if I can get all
> 64, then live would be much better.

It's not as nice as native, but GMP allows arbitrary-length integers
and has bit-wise operators.

http://www.php.net/gmp

-adam

-- 
adam@trachtenberg.com | http://www.trachtenberg.com
author of o'reilly's "upgrading to php 5" and "php cookbook"
avoid the holiday rush, buy your copies today!

---

## #21824 — Andrey Hristov — 2006-02-09T19:31:26+00:00

URL: https://externals.io/message/21820#21824 · In reply to: #21822

Ezra Nugroho wrote:
> > […]
> 
> 
> > […]
> 
> 
> Yes.
> 
> I probably should say integers that I can modify with bitwise operators
> comfortably without changing the signs.  The problem is that people may
> want to do comparison after doing bitwise operations. If the sign is
> changed, the comparison will not be valid, right?
> 
> That's why I want to stay within the positive range.
> 

Take a look at
http://pecl.php.net/package/big_int/1.0.2

Andrey

---

## #21825 — Michael Wallner — 2006-02-09T19:33:53+00:00

URL: https://externals.io/message/21820#21825 · In reply to: #21822

Ezra Nugroho wrote:

> I probably should say integers that I can modify with bitwise operators
> comfortably without changing the signs.  The problem is that people may
> want to do comparison after doing bitwise operations. If the sign is
> changed, the comparison will not be valid, right?
> 
> That's why I want to stay within the positive range.

You just don't care about signedness:

mike@honeybadger:~/development/testimonials$ ./un_or_signed
-1 4294967295 4294967295 -1 EQUAL
mike@honeybadger:~/development/testimonials$ cat un_or_signed.c
#include <stdio.h>

int main(int argc, char *argv[])
{
         signed i1 = -1;
         unsigned i2 = -1;

         printf("%d %u %u %d %s\n", i1, i2, i1, i2, i1==i2?"EQUAL":"DIFFER");

         return 0;
}

Regards,
-- 
Michael - <mike(@)php.net> http://dev.iworks.at/ext-http/http-functions.html.gz
