The conversion scans all leading digits and underscore characters ( _ ) and stops as soon as it encounters any other character or the end of the string. It returns zero if no digits were encountered.
Both str.atoi() and color.atoi() should return 0, so your simulator has a bug. The atoi function returns an integer type, whose bits can be either 0, 1, x, or z. So that might be why it returned z rather than 0.