Add overflow detection to tangent number calculation.