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

      

  • 相关阅读:
    JAVA面向对象概述
    练习
    字符串
    图形代码
    assets转到内外部存储
    file存储
    sp存储
    Intent练习
    存储登录
    存储
  • 原文地址:https://www.cnblogs.com/Phoebe815/p/3889941.html
Copyright © 2011-2022 走看看