I have never used long integer or BigInteger format numbers in my Java code, and this aspect of the IP2Location databases does not appear to be documented. I need to know which it is, so that I can write some simple code to compare numbers for greater that or equal. Here are a couple of lines of data from the file...
"281470698522624","281470698524671","CN","China","Guangdong","Guangzhou"
"281470698524672","281470698528767","JP","Japan","Tokyo","Tokyo"
EDIT: The two numbers at the beginning of each line represent a range of IP addresses that are located in the city identified by the last 4 entries on the line. I convert my IP address to a decimal notation following a known algorithm, then search thru the file sequentially until I find a second number that is greater than or equal to my IP. Then I have the location data :) QED
Hope you can help, Mick :)
You asked:
They are
longvalues.In Java, you can see the
minandmaxby using settingMIN_VALUEandMAX_VALUEfor each ofByte, Short, Integer, Long, Float, and Double. You can see how many bits wide they are by using SIZE.Examples:
prints
Check out Double and Float for more constants such as MIN_EXPONENT and PRECISION.
For requirements exceeding those types, check out BigInteger and BigDecimal
Also, if you want to find the maximum number of digits, in a
long(similar forint, short, or byte, you can do the following:prints
This says there can be between
19and20digits. All longs can have19digits but some longs with20will overflow the63bit size limit for positive numbers.