From 67c505efc58146a5e9612516705e570dcf032916 Mon Sep 17 00:00:00 2001 From: EnascutaRazvan <79245049+EnascutaRazvan@users.noreply.github.com> Date: Tue, 18 Mar 2025 16:40:30 +0200 Subject: [PATCH 1/3] fix: casting to float lose precision in some cases #10391 Related to -> #10391 --- .../orient/core/sql/parser/OFloatingPoint.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OFloatingPoint.java b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OFloatingPoint.java index 1f0714a8377..6ee2439d162 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OFloatingPoint.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OFloatingPoint.java @@ -40,11 +40,7 @@ public Number getValue() { } else { try { double returnValue = Double.parseDouble(stringValue) * sign; - if (Math.abs(returnValue) < Float.MAX_VALUE) { - finalValue = (float) returnValue; - } else { - finalValue = returnValue; - } + finalValue = returnValue; } catch (Exception ignore) { return null; // TODO NaN? } From fa699f83018b879ba1ae6510cda5a09e5a988032 Mon Sep 17 00:00:00 2001 From: EnascutaRazvan <79245049+EnascutaRazvan@users.noreply.github.com> Date: Thu, 20 Mar 2025 07:55:18 +0200 Subject: [PATCH 2/3] fix: cast to float lose precision --- .../orient/core/sql/parser/OFloatingPoint.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OFloatingPoint.java b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OFloatingPoint.java index 6ee2439d162..e5f5cfd2c5e 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OFloatingPoint.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OFloatingPoint.java @@ -40,7 +40,13 @@ public Number getValue() { } else { try { double returnValue = Double.parseDouble(stringValue) * sign; + float floatValue = (float) returnValue; + double check = (double) floatValue; + if(check == returnValue) { + finalValue= floatValue; + } else { finalValue = returnValue; + } } catch (Exception ignore) { return null; // TODO NaN? } From e9e0ce7bc90b5405343d237d03b379344c019343 Mon Sep 17 00:00:00 2001 From: EnascutaRazvan <79245049+EnascutaRazvan@users.noreply.github.com> Date: Thu, 20 Mar 2025 08:05:04 +0200 Subject: [PATCH 3/3] fix: casting to float lose precision in some cases #10391 --- .../orient/core/sql/parser/OFloatingPoint.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OFloatingPoint.java b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OFloatingPoint.java index e5f5cfd2c5e..03b7af4d6c1 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OFloatingPoint.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/parser/OFloatingPoint.java @@ -42,8 +42,8 @@ public Number getValue() { double returnValue = Double.parseDouble(stringValue) * sign; float floatValue = (float) returnValue; double check = (double) floatValue; - if(check == returnValue) { - finalValue= floatValue; + if (check == returnValue) { + finalValue = floatValue; } else { finalValue = returnValue; }