# Why is one of the test case so annoying?

• I've tried calculating the slopes and count them using map, but was failing a test case all the time. No matter how many digits I set for the float it just seemed that 94911150/94911151 equals 94911151/94911152.

???!

It was crazy. Anyone could help me?

• i did something like:

``````double slope = 10000000000000.0 * double(points[i].y - points[j].y) / double(points[i].x - points[j].x);
``````

seems work, could pass the test case but might cause some overflow problem in the future...
actually 10.0 is enough:

``double slope= 10.0*(points[i].y-points[j].y)/(points[i].x-points[j].x);``

• @shenjunsu That works. I was trying to use BigDecimal. Does not work out a solution.

• @shenjunsu That's just luck. It fails other cases. For example `10000000000000.0 * 61842131 / 61842132 == 10000000000000.0 * 61842132 / 61842133` and `10.0 * 75037253 / 75037254 == 10.0 * 75037254 / 75037255`.

@KylinZenda Those two values, as computed by floats, actually are equal. They're both exactly 0.999999989463830285529866159777157008647918701171875. Try it with `"{0:.70f}"` and you'll see there are only zeros after that.

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.