Ipv6 range query

Assuming I have two ipv6 addresses that represent a range, what is the best way to store the data so I can use a query to see if another ipv6 address is within that range? Would converting to a 128 bit number work? Are numbers that large supported? Is there a better way?


N1QL support number which is float64 2**64 ( high end numbers can loose precision due to floating point rounding).

You can can convert 128 bit into string of fixed length (leading/trailing zeros). Then You can do range comparison on strings.

Example: "000000000000000000000000000000000011000" < "000000000000000000000000000000000110000"

If ipv6 address ranges are left to right you can convert individual parts has leading/trailing zeros with fixed length.

Check this how timestamp is stored in ISO-8601 format can easily string comparable (https://fits.gsfc.nasa.gov/iso-time.html). Use similar technique


The method should would with HEX numbers represented as strings correct?

I know representation of decimal numbers will work. not sure about HEX numbers you need to verify