|
|
back to boardhow you compare doubles? Persons, who got AC without long arithmetics,tell me how did you comapre doubles? I used construction: fabs(r-l)>eps,where eps=1e-15, and i'm getting wa5 every time. Please,somebody, help me to find the bug, I need it in my work to solve polinomial of 5-th degree.My code available for looking - my judge id - 77493FG, password - shared, last submissions - 1503 problem. If somebody will find bug in my code,please write it on this thread. Edited by author 01.02.2011 09:52 Re: how you compare doubles? up Re: how you compare doubles? up, blyat,up! Re: how you compare doubles? Posted by hoan 10 Feb 2011 17:59 I dont use binary-search with double all in my life but i think you can use long long instead of double, and for every expresion you devide the parameter by 10^7. like this: double a= 1.1234567; cout << a * 1e-1 << endl; ---> 0.11234567 you can use: long long a= 11234567; cout << ((long double)a * 1e-7) * 1e-1 ---> 0.11234567 I hope can help you Edited by author 10.02.2011 17:59 Re: how you compare doubles? thanks for advice, but it seems impossible for me to use long long because my aim is not submit 1503 problem, but care about cases when coefficients of polinomial is large enough - 10^20,10^30 - i need it in my work.Long long doesn't allow to store such large numbers as I need. Also, I red in the forum that somobody accepted this problem with algorithm similar to mine, so my approach is correct but has some troubles with precision. Anyway, a lot of thanks for advice! |
|
|