Implements a num() function for converting values to number.