John Jai wrote:What happened when you tried to give input as 0:0:0:0:0:0:0:1?
unforeseen exception, otherwise the problem would not arise at all, obviously.
No, it's not obvious at all. There are many different things that could go wrong.
For instance: How many bits in an IPv4 address? How many bits in an IPv6 address? How many bits in an int? How many bits in a long?
Also, you definitely don't want to use math.pow() to shortcut integer multiplication, or bring doubles into it in any way. There are values that long can represent that double can't, so the double version of a long may lose precision--you may not end up with the value you expect.