From fc83cb24d440c423ee8dcf3e83d652fc3c40a5c2 Mon Sep 17 00:00:00 2001 From: Thomas Leplus Date: Thu, 16 Sep 2021 21:43:25 -0700 Subject: [PATCH] NaN comparison always returns false Using == with NaN doesn't work as expected. See https://www.baeldung.com/java-not-a-number for details. --- .../baksmali/adaptors/Format/InstructionMethodItem.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/atlas-gradle-plugin/dexpatch/src/main/java/com/taobao/android/baksmali/adaptors/Format/InstructionMethodItem.java b/atlas-gradle-plugin/dexpatch/src/main/java/com/taobao/android/baksmali/adaptors/Format/InstructionMethodItem.java index 2c8bf683d..395a53f9d 100644 --- a/atlas-gradle-plugin/dexpatch/src/main/java/com/taobao/android/baksmali/adaptors/Format/InstructionMethodItem.java +++ b/atlas-gradle-plugin/dexpatch/src/main/java/com/taobao/android/baksmali/adaptors/Format/InstructionMethodItem.java @@ -502,7 +502,7 @@ protected void writeCommentIfLikelyFloat(IndentingWriter writer, int val) throws writer.write("Float.POSITIVE_INFINITY"); else if (fval == Float.NEGATIVE_INFINITY) writer.write("Float.NEGATIVE_INFINITY"); - else if (fval == Float.NaN) + else if (Float.isNaN(fval)) writer.write("Float.NaN"); else if (fval == Float.MAX_VALUE) writer.write("Float.MAX_VALUE"); @@ -529,7 +529,7 @@ protected void writeCommentIfLikelyDouble(IndentingWriter writer, long val) thro writer.write("Double.POSITIVE_INFINITY"); else if (dval == Double.NEGATIVE_INFINITY) writer.write("Double.NEGATIVE_INFINITY"); - else if (dval == Double.NaN) + else if (Double.isNaN(dval)) writer.write("Double.NaN"); else if (dval == Double.MAX_VALUE) writer.write("Double.MAX_VALUE");