Deal with floating point numbers in cast()