Author Topic: Using BIGINT in PHP, how you do this?  (Read 1456 times)

Offline Wakish

  • Level 14
  • *
  • Posts: 111
  • Reputation: +0/-1
    • View Profile
    • Wakish Wonderz
Using BIGINT in PHP, how you do this?
« on: May 04, 2008, 05:21:21 AM »
BIGINT is the MySql type with a range exceeding the actual PHP range for an INT

INT =>  (+/-) 2,147,483,648
BIGINT => (+/-) 9,223,372,036,854,775,807

My question is "how do you make use of BIGINT with PHP?
I haven't found a proper solution to this..

Offline Zeggy

  • Global Moderator
  • Level 35
  • *****
  • Posts: 1,187
  • Reputation: +13/-4
    • View Profile
Re: Using BIGINT in PHP, how you do this?
« Reply #1 on: May 04, 2008, 12:05:14 PM »
You could use these functions:

http://www.php.net/manual/en/book.gmp.php

Offline Wakish

  • Level 14
  • *
  • Posts: 111
  • Reputation: +0/-1
    • View Profile
    • Wakish Wonderz
Re: Using BIGINT in PHP, how you do this?
« Reply #2 on: May 10, 2008, 01:11:59 PM »
You could use these functions:

http://www.php.net/manual/en/book.gmp.php

I'm not too convinced by those funtions.. :S
No one has ever tried to work with BIGINTs here? weird..

Offline Zeggy

  • Global Moderator
  • Level 35
  • *****
  • Posts: 1,187
  • Reputation: +13/-4
    • View Profile
Re: Using BIGINT in PHP, how you do this?
« Reply #3 on: May 10, 2008, 03:12:16 PM »
Well, the thing is, PHP simply can't work with such huge numbers with its basic math operators. (The number depends on the platform you run it on, but it's probably 32 bits)

That's why you need to use specialized functions such as the GMP library.

If you want, you can change the limit in the PHP pre-defined constants. Edit PHP_INT_SIZE and PHP_INT_MAX.

Offline JohnMunsch

  • Level 7
  • *
  • Posts: 32
  • Reputation: +1/-0
    • View Profile
    • JohnMunsch.com
Re: Using BIGINT in PHP, how you do this?
« Reply #4 on: May 10, 2008, 10:35:05 PM »
If those constants are anything like similar constants in C, C++, or Java though, they don't change the actual implementation underneath. You would just have wrong limits when you used them, not more range within an int.
My PBBG development blog is at http://MadGamesLab.com

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal