GitHub user dbtsai opened a pull request:

    https://github.com/apache/spark/pull/1425

    [SPARK-2479][MLlib] Comparing floating-point numbers using relative error 
in UnitTests

    Floating point math is not exact, and most floating-point numbers end up 
being slightly imprecise due to rounding errors. Simple values like 0.1 cannot 
be precisely represented using binary floating point numbers, and the limited 
precision of floating point numbers means that slight changes in the order of 
operations or the precision of intermediates can change the result. That means 
that comparing two floats to see if they are equal is usually not what we want. 
As long as this imprecision stays small, it can usually be ignored.
    See the following famous article for detail.
    
http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
    For example:
    float a = 0.15 + 0.15
    float b = 0.1 + 0.2
    if(a == b) // can be false!
    if(a >= b) // can also be false!
    
    (ps, not all the tests involving floating point comparisons are changed to 
use almostEquals) 

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/AlpineNow/spark 
SPARK-2479_comparing_floating_point

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/1425.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1425
    
----
commit f4da8f4f8693763b4823e36e3d270b74a7ce67bf
Author: DB Tsai <dbt...@alpinenow.com>
Date:   2014-07-14T23:24:11Z

    Alpine Data Labs

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to