I have some trouble to deal the value of 'NaN'. For example, > exp(1e3) [1] Inf > exp(1e3)*0 [1] NaN The correct answer should be 0 rather than NaN. I will very appreciate if anyone can share some technique to get a correct answer.