Ignore:
Timestamp:
2015-05-17T15:52:24+02:00 (9 years ago)
Author:
Don-vip
Message:

squid:S1244 - Floating point numbers should not be tested for equality

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java

    r8373 r8384  
    1818import org.openstreetmap.josm.data.DataSource;
    1919import org.openstreetmap.josm.data.coor.EastNorth;
     20import org.openstreetmap.josm.tools.Utils;
    2021
    2122/**
     
    211212    */
    212213    public Date[] getMinMaxTimeForAllTracks() {
    213         double min=1e100, max=-1e100, t;
     214        double min=1e100;
     215        double max=-1e100;
    214216        double now = System.currentTimeMillis()/1000.0;
    215217        for (GpxTrack trk: tracks) {
    216218            for (GpxTrackSegment seg : trk.getSegments()) {
    217219                for (WayPoint pnt : seg.getWayPoints()) {
    218                     t = pnt.time;
     220                    double t = pnt.time;
    219221                    if (t>0 && t<=now) {
    220222                        if (t>max) max=t;
     
    224226            }
    225227        }
    226         if (min==1e100 || max==-1e100) return null;
    227         return new Date[]{new Date((long) (min * 1000)), new Date((long) (max * 1000)), };
     228        if (Utils.equalsEpsilon(min,1e100) || Utils.equalsEpsilon(max,-1e100)) return new Date[0];
     229        return new Date[]{new Date((long) (min * 1000)), new Date((long) (max * 1000))};
    228230    }
    229231
     
    293295                        double C = -A * rx - B * ry;
    294296                        double RSsq = A * A + B * B;
    295                         if (RSsq == 0.0) {
     297                        if (Double.doubleToRawLongBits(RSsq) == 0) {
    296298                            continue;
    297299                        }
Note: See TracChangeset for help on using the changeset viewer.