Neo4j Version: 5.21.2
Neo4j Mode
Single instance
Driver Version: 5.22.0
Operating System
Apple M2 Pro [Version 14.5 Sonoma]
Steps to reproduce
Create a float variable with a value that can't be precisely represented in binary (e.g., 17.3f)
Pass this value to a method that expects a double
Observe the value inside the method
Expected behavior
The float value should be converted to its exact double representation without loss of precision.
Actual behavior
The float value, when converted to double, shows more decimal places and a slightly different value. For example, 17.3f becomes 17.299999237060547.
Code Example:
public class Example {
public static void main(String[] args) {
float b = 17.3f;
hello((float) b);
}
public static void hello(double a) {
System.out.println("A: " + a);
}
}
Output:
A: 17.299999237060547
Additional Context
This issue occurs in the Values.value(Object value) method:
public static Value value(Object value) {
// ...
if (value instanceof Double) {
return value((double) value);
}
if (value instanceof Float) {
return value((float) value);
}
// ...
}
The conversion from float to double may lead to a change in the visible decimal representation of the number.
Impact:
This issue affects the accuracy of data stored in Neo4j when working with float values, potentially leading to unexpected results in queries.
Neo4j Version: 5.21.2 Neo4j Mode Single instance Driver Version: 5.22.0 Operating System Apple M2 Pro [Version 14.5 Sonoma]
Steps to reproduce
Create a float variable with a value that can't be precisely represented in binary (e.g., 17.3f) Pass this value to a method that expects a double Observe the value inside the method
Expected behavior
The float value should be converted to its exact double representation without loss of precision. Actual behavior The float value, when converted to double, shows more decimal places and a slightly different value. For example, 17.3f becomes 17.299999237060547. Code Example:
Output: A: 17.299999237060547
Additional Context
This issue occurs in the Values.value(Object value) method:
The conversion from float to double may lead to a change in the visible decimal representation of the number.
Impact:
This issue affects the accuracy of data stored in Neo4j when working with float values, potentially leading to unexpected results in queries.