We analyze photoionization and ion detection as a means of accurately counting ultracold atoms. We show that it is possible to count clouds containing many thousands of atoms with accuracies better than N^-1.2 with current technology. This allows the direct probing of sub-Poissonian number statistics of atomic samples. The scheme can also be used for efficient single-atom detection with high spatiotemporal resolution. All aspects of a realistic detection scheme are considered, and we discuss experimental situations in which such a scheme could be implemented.