Re: bigint support

59 views
Skip to first unread message

Jan Kohlhof

unread,
Jun 20, 2012, 4:29:08 PM6/20/12
to cakeph...@googlegroups.com
Hey,

that sounds great to me!

The problem with 32-bit systems is that PHP stores integers using 4
byte, while on a 64bit system its 8 byte. If PHP encounters an overflow
it will interpret the type as float
(http://www.php.net/manual/de/language.types.integer.php ).
You could probably fall back on preg_match checks if PHP_INT_SIZE < 8 &&
$value > PHP_MAX_INT
to determine if its a float or bigint?


> I have started working on a patch that will add support for bigint for
> the DBO. I have it mostly working on 64 bit but experiencing issues on
> 32 bit
>
> The main issue so far is Dbo::introspectType(); When passed large
> numbers eg: -2147483649 on 32 bit machines these are reported as float
> where as 64 bit will happily report it as an integer.
>
> I am guessing this is why it has not been implemented before :/
>
> Has anyone done work on this or have any ideas to work around this?
>
> rough patch so far
> : https://github.com/dogmatic69/cakephp/commits/2.2-bigint
>
> There are a number of tickets related to this:
> http://cakephp.lighthouseapp.com/projects/42648/tickets/17
> http://cakephp.lighthouseapp.com/projects/42648/tickets/2821
> http://cakephp.lighthouseapp.com/projects/42648/tickets/2311
> http://cakephp.lighthouseapp.com/projects/42648/tickets/1365
> and more...
>
> Along with some discussions here such
> as https://groups.google.com/d/msg/cakephp-core/h1dqSkIOAyM/DkHYDlM5hXkJ
>


mark_story

unread,
Jun 22, 2012, 12:39:48 PM6/22/12
to cakeph...@googlegroups.com
You might be able to work around the 32bit system limit by keeping bigints as strings for 32bit systems.  Then you won't hit the MAX_INT issues,  and people on 32bit systems have to be extra careful to not do math on them.

-Mark

Steve Found

unread,
Jun 23, 2012, 9:41:47 AM6/23/12
to cakeph...@googlegroups.com
On 19/06/12 23:42, dogmatic69 wrote:
I have started working on a patch that will add support for bigint for the DBO. I have it mostly working on 64 bit but experiencing issues on 32 bit

The main issue so far is Dbo::introspectType(); When passed large numbers eg: -2147483649 on 32 bit machines these are reported as float where as 64 bit will happily report it as an integer.

I am guessing this is why it has not been implemented before :/

Has anyone done work on this or have any ideas to work around this?


There are a number of tickets related to this:
and more...



There is the source code for a Java implementation of BigInteger here that may be of some use for ideas etc ?

http://developer.classpath.org/doc/java/math/BigInteger-source.html


Reply all
Reply to author
Forward
0 new messages