[
https://issues.apache.org/jira/browse/MESOS-1187?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14738336#comment-14738336
]
Klaus Ma commented on MESOS-1187:
---------------------------------
Thanks very much for your input :); and you're right about the precision. And
the following two article give some advise.
http://stackoverflow.com/questions/17333/most-effective-way-for-float-and-double-comparison
http://en.cppreference.com/w/cpp/types/numeric_limits/epsilon
http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
And the following code, from cppreference, will resolve your case. But, check
whether two double is equal is a complex and lots of discussion. I'd suggest to
commit the following patch firstly; if any new case, let's handle it case by
case.
{code}
bool almost_equal(double x, double y, int ulp = 2)
{
// the machine epsilon has to be scaled to the magnitude of the values used
// and multiplied by the desired precision in ULPs (units in the last place)
return fabs(x-y) < numeric_limits<double>::epsilon() * fabs(x+y) * ulp
// unless the result is subnormal
|| fabs(x-y) < numeric_limits<double>::min();
}
{code}
> precision errors with allocation calculations
> ---------------------------------------------
>
> Key: MESOS-1187
> URL: https://issues.apache.org/jira/browse/MESOS-1187
> Project: Mesos
> Issue Type: Bug
> Components: allocation, master
> Reporter: aniruddha sathaye
> Assignee: Klaus Ma
>
> As allocations are stored/transmitted as doubles many a times precision
> errors creep in.
> we have seen erroneous share calculations happen only because of floating
> point arithmetic.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)