Experts Round Table Network

Databases => MySQL => Topic started by: CrYpTiC_MauleR on June 10, 2007, 01:39:43 AM



Title: Large Integer Column Type
Post by: CrYpTiC_MauleR on June 10, 2007, 01:39:43 AM
Is there any way to store an integer where the the max unsigned value would be
340282366920938463463374607431768211456

bigint only goes as far as 18446744073709551615
right now I have the column set as varchar(39) is there any other way?


Title: Re: Large Integer Column Type
Post by: rdivilbiss on June 10, 2007, 07:50:20 AM
Before I finished reading your question I thought of suggesting varchar, which is what you are using.

Now if this value is being used with PHP and it overflows the bounds of an integer value it will be converted to a float, so you could use a double in MySQL, as you xhouldn't have rounding errors with integer values, but still I'd probably just use varchar.


Title: Re: Large Integer Column Type
Post by: CrYpTiC_MauleR on June 10, 2007, 02:04:19 PM
I had to end up using PHP's bcmath functions to calculate the numbers otherwise it goes out of range. Doing so keeps it from becoming a float but then stuck with large number that want in database as an integer so I can do queries that use < and > etc you check ranges and stuff. AFAIK putting it as varchar doesn't allow that and if it does I think it converts the string to an integer which would be wrong value.


Title: Re: Large Integer Column Type
Post by: rdivilbiss on June 11, 2007, 02:53:01 PM
Then double.