So given an IP address it is converted into binary via calculating the binary of all different segments and then joining them. For example, 12.32.18.01 converted into a binary it would amount to this number in decimal form 12*2^24 + 32*2^16 + 18*8 + 01 My question is why to go through all this trouble and calculation. Why not just get rid of the dots in the original Ip and then convert that integer into binary. So, for this example, the binary of the above example would amount to this integer in decimal 112 032 018 001. I mean what's the problem with second approach?
I am going to answer this question in two parts:
Without reaching into the depths of communication, I want to mention that the data that humans do understand(such as this answer which I am typing) is classified under Layer 7 of the TCP/IP stack. This data gets converted into analog signals that travel over the wire, and any hosts connected to these wires translate these analog signals to electric signals. Electric signals have two states, 0 and 1, which we humans call binary format. So any data on the wire would essentially be looked upon as a sequence of bits and bytes.
The IP address that you mention, is a component of the IP Protocol, and this protocol is used to carry packets end to end between two hosts on a network. So, the data would be added as a payload on top of an IP packet which contains a IP header. Any devices in between these two hosts which operate on Layer-3 of the TCP/IP stack(the network layer!) would use this header to process the packet. Similarly the end hosts would use this header to determine if the packet indeed was sent to them. The IP protocol specifies the syntax and semantics of the IP Packet header, and as you might notice the size of the fields are fixed. Now any machine which is looking at a sequence of bits coming in (with the knowledge that it is receiving the IP header) can just read as many bytes as it wants to extract every field of the header. For example, given that the system knows where the IP header starts, the system could read the first 4 bits and understand that it would just read the version of IP packet.
The conversion that you mentioned, between binary and dotted decimal, is purely for representing data in human readable format(as the other answer mentions). Tools like Wireshark do this to show details of a packet(the internals of this are fascinating). So, you can choose whichever method to convert one form to the other, but the machines don't really need to do this at the level of the TCP/IP stack where it really matters. The system doesn't really see it as a dotted decimal construct, but a data structure which consists of four 8 byte fields, (or two 16).
Hope this helps !
The dotted-decimal notation for IP Addresses is specifically a "human-readable" format. e.g. IP address 192.168.0.0 is from a private address range. The reason I mentioned "private" is to emphasize on the usefulness of dotted-decimal representation to analyze the classes/subnets that a given IP address represents.
Now, you're right that we could get rid of the dots and directly convert the IP address into an integer. But, it doesn't matter because computers understand numbers (including IP address) only in binary. So, although following notations represent one and the same thing, you might be interested in different notations based on the use-case: studying to grasp concepts, analyzing classes/subnets or debugging actual packet data from the network interface(which will be just a string of zeros/ones).