One approach is to store the decimal part of the number as an integer (for the large case, you need a wide enough data type to handle 11 digits). Perhaps perversely, you can do this in a double which offers 53-bits of precision; you may prefer to use a long long instead. Think of it as multiplying all the numbers by 10^11 before starting, though you will want to avoid reading as double and then multiplying since you might get errors that way.
I think this problem would be tough to do representing the actual numbers with doubles just because of precision issues (decimal fractions can't generally be exactly represented as finite binary fractions). On Apr 19, 3:15 pm, André <[email protected]> wrote: > Hi everybody, > Can anybody help me with this > problem:https://code.google.com/codejam/contest/842485/dashboard#s=p0 > ? > > I basically read the numbers like this: > > getline(file,line); > istringstream iss (line,istringstream::in); > iss>>tab[j]; > > But the problem is that they are too close to 0 so they get rounded. I > get for instance 0.00449602 instead of 0.00449602, even when tab is a > long double table. > > So how can I store the numbers into variables without losing any > information, and if possible without using "boost"? > > Thanks. -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-code?hl=en.
