I agree. But if he insists on doing it wasteful with floats, at least do it correct.
I am not aware about any real advantages of dividing by 1024.
1) it's quicker (the compiler will see to that)2) it's correct.
Correct: ... error-free ...
But I hate when someone presents "truths".
There is little difference between 1023 and 1024
Don't take my word for it then - check the ADC section of he datasheet.
Vref = 5V, Vin = 5V. Then analogRead() returns 1023.MeasuredVoltage = analogRead()*Vref/1024 = 1023*5/1024 = 4.9951171875error = |Vin - MeasuredVoltage| = 0.0048828125 > 0Not error-free -> not correct.Q.E.D.
Is everything in the Datasheet absolutely correct? There are mistakes, typos etc. in most Datasheets.
Not really QED, because you haven't started your assumption that a successive approximation ADC can read up to and including Vref.
I don't disagree, but the principle is important.
@, you ask "what is correct?" 1024 is correct. Because if you assume a perfect ADC dividing by the number of steps (here 1024) will give you the exact LSB.