Fixing issue #4902.

Added a check for complex numbers.