as_int raises exception on nan values.

fixes #8147