TL;DR:
Phone and Internet are different different networks, each with their own structure, protocols and addressing. Phone still uses phone numbers while Internet uses IP-addresses.
A Possible Mixup?
Could it be that you're mixing up
- Internet vs.
- Access via phone connection (dial in) vs.
- Use of internet based phone services?
Those are related but independent issues.
The Internet is a network based on IP protocol since the start. All connection on that level are done using IP addresses.
It was and still is possible to access the Internet using the phone network via a dial in point. To do so a _phone connection is dialled (usually by a modem). When done Internet Protocol is run atop that connection, using IP-Addresses for all further communication.
An existing internet connection can in turn be used to establish a voice connection using appropriate IP-services. Most commonly Voice over IP.
Bottom Line: Phone and Internet are independent but sometimes related services that may use each other.
The Question(s)
Before IPv4 addresses there were phone numbers.
And they still are.
Why did they switch to IPv4 addresses to address devices in the internet?
They never did. Phone and internet are different networks.
I thought one reason is you need addresses in the local LAN. But I could even imagine to reserve a country code (e.g. +99) for local LAN addresses.
Why? Beside that 99 is already subdivided for some Asian countries(*1), this leaves barely more than IPv4 Addresses (*2).
Another reason may be that phone numbers don't have a fixed length.
They do 15 usable dgits (*3)
So you have to store them in a string and not int.
They are (usually) stored as BCD - as there are, depending on PBX up to 16 values per digit. Considered an int that's exactly an int64 :))
Phone numbers worked well.
And they still do.
It was possible to establish a (phone/modem) connection between one person and another on the opposite site of the earth. The routing and everything else worked fine.
In that case it was a phone connection, not an internet connection. Even if that connection was used with a modem and having run IP on top.
I also know phone connections were analog only. But why do we need new addresses when switching to digital?
Digital phones systems are not the same as Internet. They are still phone connection and they use still their own signalling within their own network. Don't mix that up with Voice Over IP (VoIP). VoIP is an IP application, like HTTP or Telnet. It is not part of the phone network - but usually offers gateways to the public telephone network.
I tried to google it but found nothing.
Usually a good hint that there isn't anything to be found :))
*1 - But 999 is still available.
*2 - Originally (*4) Phone numbers can have up to 15 digits (E.164), so taking off 3 (999( for a country code leaves only 12
*3 - Phones and exchanges usually have a 16 digit buffer to hold as well one additional control code.
*4 - This was extended to 20 for 3GPP aka mobile phone networks.
https://BR-549♪2/
? You might want to read up on the North American Numbering Plan for a better appreciation of a segment of the global telephone number space. And Internet Protocol version 4. How do you tell DNS names from addresses when some "numbers" are "SueThemAndWinBig"? Routing tables full of arbitrary strings? An address space that was already being exhausted? Party lines and multicasting? Extensions? Network and international access codes?