system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: How our phones, iPods, laptops and other devices know the exact percentage of battery remaining.
gpt
Besides everyone saying that either they don't, or that it's based just on voltage- modern devices use something called a Coulomb Counter which actually measures the quantity of charge leaving or entering the battery. 

Imagine you have a water tank. Every few seconds, you check a meter to see how fast water is coming out of the tap. Then you can add up these measurements to figure out pretty closely how much is left in the tank!

Technically speaking, the device measures current consumption rapidly and performs integration to give a figure of amp-hours or watt-hours consumed.