Details
-
Bug
-
Resolution: Invalid
-
P3: Somewhat important
-
None
-
6.7, dev
-
None
Description
The minimal example produces values that do not consider the sign bit:
#include <QApplication> #include <QJsonDocument> #include <QJsonObject> #include <cmath> int main(int argc, char *argv[]) { QJsonDocument doc = QJsonDocument::fromJson("{\"test\":-0}"); QJsonObject obj = doc.object(); auto d = obj.value("test").toDouble(); // Expected to be "true" qDebug() << "Sign bit: " << std::signbit(d); d = -0; obj.insert("test", d); doc.setObject(obj); // Expected to be {"test":-0} qDebug() << "Resulting JSON: " << doc.toJson(QJsonDocument::Compact); return 0; }
It's insignificant, but some implementations(the one is used in protobuf) consider and preserve the sign of zero when (de)serializing floating point values.
Attachments
Issue Links
- is required for
-
QTBUG-120077 JSON serializer doesn't consider sign bits of floating point values.
-
- Open
-