From 92efb3da51a3d0e819ccab92fbfea8d1f5d05b38 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sat, 20 Aug 2022 21:08:35 -0500 Subject: [PATCH] Change the comparison method for doubles. Co-authored-by: sigonasr2 --- readers/Reader.java | 8 ++++++-- sigPlace.java | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/readers/Reader.java b/readers/Reader.java index ce1203c..036e64f 100644 --- a/readers/Reader.java +++ b/readers/Reader.java @@ -301,7 +301,11 @@ public abstract class Reader{ } } } - return Double.parseDouble(Integer.toString(numb)+"."+Integer.toString(decimal)); + try { + return Double.parseDouble(Integer.toString(numb)+"."+Integer.toString(decimal)); + } catch (NumberFormatException e) { + return 0; + } } int convertToInt(String[]data){return convertToInt("",data);} @@ -438,7 +442,7 @@ public abstract class Reader{ if (this.other.length()>0 && other.other.length()>0 && !this.other.equals(other.other)) { return false; } - if (Double.doubleToLongBits(pct) != Double.doubleToLongBits(other.pct)) { + if (Double.compare(pct,other.pct)!=0) { System.out.println("Doubles don't match!"); return false; } diff --git a/sigPlace.java b/sigPlace.java index 82f88f6..6f188ef 100644 --- a/sigPlace.java +++ b/sigPlace.java @@ -107,7 +107,7 @@ public class sigPlace { Reader lastReader = null; Reader lastSubmittedReader = null; int matches=0; - final int EXPECTED_MATCHES=7; + final int EXPECTED_MATCHES=5; boolean submitted=false; while (true) { BufferedImage screenshot = r.createScreenCapture(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds());