# Controlling overflow and loss of precision during floating point multiplication

I have a large number of floating point numbers (~10,000 numbers) , each having 6 digits after decimal. Now, the multiplication of all these numbers would yield about 60,000 digits. But the double range is for 15 digits only. How can I get my product with minimum loss in precision?

I thought of storing the numbers as 6 digit long long integers and storing their exponents elsewhere. But this appears cumbersome and may not yield correct result. Is there an alternate easier way to do this?

• As it is your question is not precise enough. Are your numbers exact values from the point of view of your problem, or are they only 6 digit approximations to begin with (e.g. results from physical measurements). Most likely, it is the latter, but you should make it clear in the question, either by saying so or giving the context of the problem. In that case, there are precise rules that define the meaningful number of digits in the result (which is not likely to be 60.000), and to give a proper estimate on the computational uncertainty on that result. – babou Jul 12 '15 at 9:48

Multiplication of floating point numbers is considered uncritical with respect to accuracy. If your input is only accurate to 6 digits, there is no point in computing the output to 60,000 digits. The expected relative error after 10,000 multiplications is $\sqrt{10,000}\epsilon=100\epsilon$ with $\epsilon<10^{-14}$ for double precision. This is more than enough precision for your case.