How to define a large integer?
I want to convert ip address to a digital, like this:
PHP Code:
|
Re: How to define a large integer?
Explain what exactly you want to do.
|
Re: How to define a large integer?
Check this: http://forums.alliedmods.net/showthr...58#post1529958
My code in that post contains ip_to_num function. |
Re: How to define a large integer?
My goal is to convert IP numbers from 0 to 4294967295
However, the default variable is -2147483648 to 2147483647 If the calculation result is greater than 2147483647, the actual output is a negative number: Actual output = The results - 4294967296 How to set variable unsigned? |
Re: How to define a large integer?
You could store bytes separately and let mysql convert it to a single number or you could store numbers in a string and implement your own * and + operators working on strings, but to me it kinda looks like XY problem: your real goal is probably not to convert ip to unsigned int, but to do something with ip ranges, so why don't you explain what do you want to do with those ips and we will see if there is better solution.
|
Re: How to define a large integer?
There is no unsigned data type in Pawn. As Sylwester says, explain better what you want to do, you can accomplish this if you're working with ranges
Easier way to load data into a cell: new IP[ 1 ] IP{ 0 } = 128 IP{ 1 } = 12 IP{ 2 } = 221 IP{ 3 } = 125 IP[ 0 ] holds address |
Re: How to define a large integer?
I put the IP address of the data conversion from 0 to 4294967295, stored in a mysql database.
In AMXX, I need to use the player's IP address lookup players come from. So I need to convert the player's IP address is a positive integer from 0 to 4294967295, to the mysql database queries. If I can not define variables in AMXX as a large integer or unsigned integer, I may only modify the database of preservation methods to adapt to AMXX. |
Re: How to define a large integer?
That's not an explanation I asked for. I'm asking what are you going to do with table full of those converted ips. Why are you using something like this: ... WHERE (`ipstart` <= '%d') And (`ipend` >= '%d') ... ?
|
Re: How to define a large integer?
My IP address data like this:
0.0.0.0 0.255.255.255 IANA reserved address ...... 192.168.0.0 192.168.255.255 Lan ...... Style in the database: ipfrom ipto address 0 16777215 IANA reserved address ...... 3232235520 3232301055 Lan ...... If I want to check the IP address 192.168.1.101 come from. First I must change 192.168.1.101 converted to digital: 3232235877(192*256*256*256+168*256*256+1*256+ 101), and then query the database to get the final result is "Lan" |
Re: How to define a large integer?
So do you only want to verify if two parts of IP are same? 192.168.x.x?
|
| All times are GMT -4. The time now is 14:22. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.