ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1503. Polynomial

how you compare doubles?
Posted by Baurzhan 1 Feb 2011 09:51
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?
Posted by Baurzhan 6 Feb 2011 09:52
up
Re: how you compare doubles?
Posted by Baurzhan 8 Feb 2011 11:11
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