-
Type: Bug
-
Resolution: Fixed
-
Priority: Critical - P2
-
Affects Version/s: bson-4.7.1, bson-5.0.0
-
Component/s: None
What problem are you facing?
Large doubles that stringify with an exponential component will be suffixed with a trailing ".0". This will successfully roundtrip in JavaScript, because parseFloat begins ignoring a string once it encounters an invalid character. Other languages like Java will throw an exception for the incorrect formatting.
const d = new BSON.Double(Number.MAX_VALUE); d.toExtendedJSON() // { '$numberDouble': '1.7976931348623157e+308.0' }
What driver and relevant dependency versions are you using?
Introduced in BSON v4.7.1
Steps to reproduce?
Launch jshell
jshell> Double.valueOf("1.7976931348623157e+308.0") | Exception java.lang.NumberFormatException: For input string: "1.7976931348623157e+308.0" | at FloatingDecimal.readJavaFormatString (FloatingDecimal.java:2054) | at FloatingDecimal.parseDouble (FloatingDecimal.java:110)