-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathepsilon.java
More file actions
27 lines (24 loc) · 743 Bytes
/
Copy pathepsilon.java
File metadata and controls
27 lines (24 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
public class epsilon{
public static void main(String[] args){
double a = 5.423483762;
double b = 5.423480959;
double c = 3.3849859843758;
System.out.println(epsilonFunc.floorToNearestEpsilon(c));
System.out.println(epsilonFunc.equal(a,b));
System.out.println(epsilonFunc.equal(a,c));
System.out.println(epsilonFunc.equal(c,b));
}
}
class epsilonFunc{
private static double e = .00001;
public static double floorToNearestEpsilon(double d){
int temp = (int) (d / e);
return (double)temp * e;
}
public static boolean equal(double a, double b){
if(Math.abs(a-b) >= e)
return true;
else
return false;
}
}