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的更多相关文章

  1. ural 1433. Diamonds

    1433. Diamonds Time limit: 1.0 secondMemory limit: 64 MB Sasha is lucky to have a diamond in the for ...

  2. js实现省市区联动

    先来看看效果图吧,嘻嘻~~~~~~~~~~~~~~~~~~~· 代码在下面: 示例一: html: <!DOCTYPE html> <html> <head> &l ...

  3. [LeetCode&Python] Problem 453. Minimum Moves to Equal Array Elements

    Given a non-empty integer array of size n, find the minimum number of moves required to make all arr ...

  4. C++ little errors , Big problem

    ---------------------------------------------------------------------------------------------------- ...

  5. POJ 3100:Root of the Problem

    Root of the Problem Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12060   Accepted: 6 ...

  6. [LeetCode] The Skyline Problem 天际线问题

    A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...

  7. Manthan, Codefest 16(B--A Trivial Problem)

    B. A Trivial Problem time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  8. The Solution of UESTC 2016 Summer Training #1 Div.2 Problem B

    Link http://acm.hust.edu.cn/vjudge/contest/121539#problem/B Description standard input/output Althou ...

  9. C - NP-Hard Problem

    C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144 ...

随机推荐

  1. Vmware怎样使用nat和桥接方式解决虚拟机联网问题

    对于很多的linux初学者来说,最开始学习linux时通常是在虚拟机上进行的,然而对于新手来说虚拟机联网会对他们来说是比较困难的.这里我根据自己的经验写了一篇文档分享给大家.下面对几种连接方式进行简单 ...

  2. Vmware虚拟机

    1.在虚拟机安装完系统后找到相对应的保存路径如:D:\VMware\VOS\Win7x64OS 2.该目录下面会有很多文件和文件夹,其中配置文件Windows 7 x64.vmx和硬盘文件Window ...

  3. 使用twisted.web实现代理服务器

    简单的实现谷歌的代理: 架构就是下面这么简单. ================= my server outside GFW  |    <----------------------> ...

  4. 通过JS语句判断WEB网站的访问端是电脑还是手机

    通过JS语句判断WEB网站的访问端是电脑还是手机,以显示不同的页面! 目录腾讯网的适配代码如何判断访问网站的机器类型-如何判断ipadJS 判断浏览器客户端类型(ipad,iphone,android ...

  5. CentOS 初始化时的分区

    /            ext3    8189   固定大小 空          swap    509   固定大小 /boot     ext3     100   固定大小 /home   ...

  6. 【USACO】namenum

    //开始傻×了 受题目形容的误导 一心想生成所有可能的 字符串组合 之后查找非常慢 //听了同学的 将5000个dict里的字符串 转换成char型数组(不能直接用int 会越界)直接用输入的数据对着 ...

  7. [Android Pro] Android签名与认证详细分析之二(CERT.RSA剖析)

    转载自: http://www.thinksaas.cn/group/topic/335449/ http://blog.csdn.net/u010571535/article/details/899 ...

  8. 使用Memory Analyzer tool(MAT)分析内存泄漏(二)

    转载自:http://www.blogjava.net/rosen/archive/2010/06/13/323522.html 前言的前言 写blog就是好,在大前提下可以想说什么写什么,不像投稿那 ...

  9. July 14th, Week 29th Thursday, 2016

    Risk comes from not knowing what you are doing. 风险常常来自于不知道自己在做什么. What is risk? I think risk means t ...

  10. css3学习总结3--CSS3图像边框

    border-image属性 .className{ border-image:url(/course/54d1cae088dba03f2cd1fec1/img/border.png) 20 20 2 ...