# analogRead - divide by 1023 or 1024?

AWOL: Nope You only know that the voltage was greater than 4.99xxx Volts

True. Higher voltages than Vref are obviously possible. I'll update my post.

I didn’t say I recommended rounding up. In most cases I would prefer to round to nearest by adding 0.5 LSb so that it has an average error of 0.

[quote author=Nick Gammon date=1424894323 link=msg=2111955] No, I don't think so. The answer given below your reply, of adding 0.5 to the reading, seems more correct than dividing by a different number than that recommended in the datasheet.[/quote] Yes, adding 0.5 to the reading is more correct for the AVR, but I was asking this question with regards to the Due (SAM) where it looks to me like its already doing something similar to this in hardware.

If true, then applying this method on the SAM would result in doing the same thing twice, thereby increasing the error. I wonder what the most correct method on the SAM architecture would be?

Since every ADC step corresponds to a voltage interval, we have a choice of mapping a reading to the floor, mean or ceiling of that interval. This results in variations of V = (analogRead(pin) + k) * AREF / 1024; with k of 0 for floor 0.5 for mean 1 for ceiling