The 5v supply of the microcontroller is connected to the VREF pin. (Voltage reference). So if your sensor reading is outputting 2.5 volts, the microcontroller will divide 5 by 2.5 to get one-half, and then multiply it by 255 (for 8 bit ADC). I doubt the microcontroller actually goes through multiplying and dividing (there should be a more accurate way), but thats basically how it's done.