标签:blog java io for div line log res
Understand limitations of floating point representations.Never check for equality with ==. Instead, check if the difference is less than an epsilon value.
public class Line{ static double epsilon=0.000001; public double slope; public double yintersect; public Line(double s, double y){ slope=s; yintersect=y; } public boolean intersect(Line line2){ return Math.abs(slope-line2.slope)>epsilon|| Math.abs(yintersect-line2.yintersect)<epsilon; } }
Float Equal Problem,布布扣,bubuko.com
标签:blog java io for div line log res
原文地址:http://www.cnblogs.com/Phoebe815/p/3889941.html