If you want your results to read 0 to Vref and are willing to live with less error than you can measure, divide by 1023.If you want to be a pedantic-retentive obsessed with correctness you can never show or use, divide by 1024 and feel superior.
Doing things deliberately wrong/incorrect would make me feel dumb, how about you?
PS -- I get a big laugh at people who go on about preserving the "purity" of what is not pure.
In real life, we all bodge things, but I still think it is better if you know the underlying principles, for those edge cases where it will matter
Now that my interest has been awoken sufficiently to read the Atmega328 datasheet ...The data sheet clearly states what is in Reply #2ADC = (VIN * 1024) / VREFHowever if you imagine a very crude ADC that can only report the values 0, 1, 2, 3, 4 and 5 for a range of 0v to 5v you can easily see that the only sensible calculation isADC = VIN * number of intervals / VREFFor example, if Vref is 5v and Vin is 3v the calculation will be 3 * 5 / 5 = 3For the Atmega 328 the number of intervals is 1023, not 1024. And if the crude ADC was to mimic the Atmega datasheet the calculation would be 3 * 6 / 5 = 3.6 which should round to 4 and which would be incorrect. Of course an integer only system would report 3 (rounding down) so the error would not appear.All of which leads me to believe that the Atmega 328 ADC is not sufficiently precise for it to matter whether you use 1023 or 1024. And that the assertion that started this Thread has no basis in theory and (as the OP acknowledged) does not matter in reality....R(Runs for bomb shelter)
28.6.3.ADC Accuracy DefinitionsAn n-bit single-ended ADC converts a voltage linearly between GND and V REF in 2 n steps (LSBs). Thelowest code is read as 0, and the highest code is read as 2 n -1.
The ADC does have 1024 steps. The zero step covers 0V to Vref/1024 (just under 5mV whenVref is 5V) returning 0.
char buff[ 1024 ]; // has how many elements and what is the high index?