system
Given the following post, respond as if you're commenting on Reddit:
human
How do electronics measure battery percentage?
gpt
Two ways:

1) They can measure the battery voltage and using a pre-programmed chart of this particular battery type's voltage vs. capacity, they can estimate the remaining percentage.

2) They can continuously measure the current into and out of the battery, and by integrating this over time get a direct measurement of the amp hours drained from the battery.  Doing the math with the known battery capacity gives the percentage.