A cylinder is standing upright and has a height of 10 units and a diameter of 4 units. If a sphere is perfectly encased within the cylinder, touching the top, bottom, and sides, what is the diameter of the sphere?