If possible make sure the voltage you are measuring is stable (i.e not changing) as there will be some time (for the C code to execute, this could be reduced by moving to assembler, but likely isn't worth it) so if you are measuring a varying signal you will get slightly (or a lot if it is varying fast and the A/D converter is fast) different results. That should tell you if the Mega is functioning correctly, if it is and your original task still isn't behaving then you are likely in to the fun of analog circuit design and sampling theory.
Peter Van Epp