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;
    }
}
Float Equal Problem的更多相关文章
- ural 1433. Diamonds
		
1433. Diamonds Time limit: 1.0 secondMemory limit: 64 MB Sasha is lucky to have a diamond in the for ...
 - js实现省市区联动
		
先来看看效果图吧,嘻嘻~~~~~~~~~~~~~~~~~~~· 代码在下面: 示例一: html: <!DOCTYPE html> <html> <head> &l ...
 - [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 ...
 - C++   little errors , Big problem
		
---------------------------------------------------------------------------------------------------- ...
 - POJ 3100:Root of the Problem
		
Root of the Problem Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12060 Accepted: 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 ...
 - 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 ...
 - 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 ...
 - C - NP-Hard Problem
		
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
 
随机推荐
- backbone杂记
			
国人的一个不错的分享:http://gavin.iteye.com/blog/1446277 backbone项目如何组织文件结构 引用: http://bocoup.com/weblog/organ ...
 - C++代码重用——包含
			
#ifndef PAIRS_H #define PAIRS_H #include <iostream> #include <valarray> template <cla ...
 - 在windows下用cygwin和eclipse搭建cocos2dx(2.1.4)的android开发环
			
一.准备工作 需要下载和安装以下内容,请根据自己的操作系统选择x86和x64(我的是64位win7,我就拿64位说事) 1.jdk-7u25-windows-x64.exe(下载完后直接安装,一直下一 ...
 - Solr5.3.1通过copyField设置多个field(字段)同时检索
			
如果业务需要我们对多个field同时进行检索,有没有什么好的办法呢?非常幸运的是Solr为我们提供了copyField对多个field进行索引和检索.然而配置也非常简单. 修改schame.xml,添 ...
 - 【转】打造属于自己的Android Studio神器
			
本文转载自:http://www.stormzhang.com/android/2015/05/26/android-tools/,并加以修改.黄色底部分是本人添加的内容. 一晃好久没更新博客了,最近 ...
 - iOS的 context 和Android 中的 canvas
			
ios 想要绘图,要用到CGContextRef类.最基本的用法是在- (void)drawRect:(CGRect)rect 函数中绘制. Android 中要用到Canvas类.最基本的用法是在 ...
 - Android Services重点记录
			
今天阅读了google的官方文档 Services,对重点做下记录. 首先,Services默认运行在主线程中,所以一般情况下,要手动创建一个thread. 系统除了Services,还为我们提供了一 ...
 - 转MYSQL学习(三) 函数
			
这一节主要介绍MYSQL里的函数,MYSQL里的函数很多,我这里主要介绍MYSQL里有而SQLSERVER没有的函数 数学函数 1.求余函数MOD(X,Y) MOD(X,Y)返回x被y除后的余数,MO ...
 - 5.python(迭代器,装饰器,生成器,基本算法,正则)
			
一,迭代器 1.迭代器 (1)迭代器是访问集合元素的一种方式.迭代器对象从集合的第一个元素开始访问,知道所有的元素被访问完结束.迭代器只能往前不会后退. (2)对于原生支持随机访问的数据结构(如t ...
 - [Android Pro]   UI设计师不可不知的安卓屏幕知识
			
reference to : http://www.android100.org/html/201505/24/149342.html 不少设计师和工程师都被安卓设备纷繁的屏幕搞得晕头转向,我既做UI ...