Max Integer problem
#1

Max Integer value is 2.1billion (21xx.xxx.xxx). I'm currently scripting a RP phone system which uses a 10 digit phone number for every player. As Max Integer value also reaches to 10 digits, it cannot go pass (in the first three prefix, aka area code) 217, while my script uses different area codes including 671 and 842. Basically my integer values are destined to cross the restrictions, making my value go below 0. I know it's not possible to mess around with the integer limits, but what I'm looking for is a workaround. Saving the number as a string in the userfile is not an option, since there will HAVE to be a time I'll be using the number as an integer which will again corrupt the value. I've thought about using two integers and joining them together each time the number is needed for printing or to show the player, but values still go below 0. Any help, much appreciated.
Reply
#2

I'm not sure if that's going to work but, in case you're having mySQL as your database, you could choose the long variable, so you can enter a higher number value then the maximum integer value.
(long is double than int)
Int max value = (2,147,483,647:-2,147,483,648)
Long max value = (9,223,372,036,854,775,807:-9,223,372,036,854,775,808)

Although you shouldn't pass the max. int value for your phone system in my opinion.
Reply
#3

u can use strings as phone numbers or you can use 2 32bit variables and store like country and area code into first and everything else into second
Reply
#4

Why not just make it 9 digits, there is no need for 10
Reply
#5

Quote:
Originally Posted by Loot
Посмотреть сообщение
I'm not sure if that's going to work but, in case you're having mySQL as your database, you could choose the long variable, so you can enter a higher number value then the maximum integer value.
(long is double than int)
Int max value = (2,147,483,647:-2,147,483,64
Long max value = (9,223,372,036,854,775,807:-9,223,372,036,854,775,80

Although you shouldn't pass the max. int value for your phone system in my opinion.
I'm not using MySQL. Will it still work? I see the long word becoming highlighted in pawno.

Quote:

Why not just make it 9 digits, there is no need for 10

10 digits number is how it is in real. I wanna keep the RP to the max.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)