zoukankan      html  css  js  c++  java
  • Float Equal Problem

    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;
        }
    }                
    

      

  • 相关阅读:
    团队题目及相关介绍
    团队介绍
    寒假8
    寒假作业七
    寒假7
    寒假作业六
    寒假6
    寒假作业五
    寒假5
    寒假作四
  • 原文地址:https://www.cnblogs.com/Phoebe815/p/3889941.html
Copyright © 2011-2022 走看看