Support exponential writing for numbers

Fixes #684.