# unsinged integer

- Thread: https://externals.io/message/75890
- Original archive: https://news-web.php.net/php.internals/75890
- Started by Marc Bennewitz on 2014-07-22T17:50:11+00:00
- Messages: 2
- 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

---

## #75890 — Marc Bennewitz — 2014-07-22T17:50:11+00:00

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

Hi all,

I like to create an RFC to add an unsinged integer type for the
following purposes:

- higher max value
  - DBs already allow UNSIGNED INT/BIGINT which is a farce to work with
in PHP
- better support pack/unpack unsigned integers from/to PHP using the
un/pack functions
- simplified right shift of unsinged integers because PHP "safes" the
sing bit on singed integers which leads to bugs or overcomplicated code
if you need that bit for others than a sign
- if a parameter type-hint or similar functionality will be implemented
this type will be very useful, too. Else it will be also useful to make
sure you have no negative integer by simply converting to it.

What do you think?
(Does it worth the expense for a RFC?)

Marc

---

## #75897 — Andrea Faulds — 2014-07-22T22:04:04+00:00

URL: https://externals.io/message/75890#75897 · In reply to: #75890

> I like to create an RFC to add an unsinged integer type for the
> following purposes:
> 
> - higher max value
>  - DBs already allow UNSIGNED INT/BIGINT which is a farce to work with
> in PHP
> - better support pack/unpack unsigned integers from/to PHP using the
> un/pack functions
> - simplified right shift of unsinged integers because PHP "safes" the
> sing bit on singed integers which leads to bugs or overcomplicated code
> if you need that bit for others than a sign
> - if a parameter type-hint or similar functionality will be implemented
> this type will be very useful, too. Else it will be also useful to make
> sure you have no negative integer by simply converting to it.
> 
> What do you think?
> (Does it worth the expense for a RFC?)

This would be likely to cause endless problems since signed integers are used so widely and things would break on conversion, for quite limited gain.

I’m currently proposing and implementing bigints for PHP 6: http://wiki.php.net/rfc/bigint

This would solve your problem (any unsigned integer would fit) but would cause less issues.
--
Andrea Faulds
http://ajf.me/
