Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ bool fromJsonValue(QString &value, const QJsonValue &jval) {
} else if (jval.isBool()) {
value = jval.toBool() ? "true" : "false";
} else if (jval.isDouble()) {
value = QString::number(jval.toDouble());
value.setNum(jval.toDouble(), 'f', 0);
} else {
ok = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ bool fromJsonValue(QString &value, const QJsonValue &jval) {
} else if (jval.isBool()) {
value = jval.toBool() ? "true" : "false";
} else if (jval.isDouble()) {
value = QString::number(jval.toDouble());
value.setNum(jval.toDouble(), 'f', 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between value = QString::number(jval.toDouble()) and value.setNum(jval.toDouble(), 'f', 0) ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original method would turn the double value into a scientific count

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eg:

QString::number(2147483647) output  2.14748e+09
value.setNum(2147483647, 'f', 0) output 2147483647

I just want him to print it as it is, not in scientific notation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you removing the decimal ? This looks like a data degradation to me. I tested your code and value.setNum(21.474836.47, 'f', 0) output 21.

} else {
ok = false;
}
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpp-qt/client/PFXHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ bool fromJsonValue(QString &value, const QJsonValue &jval) {
} else if (jval.isBool()) {
value = jval.toBool() ? "true" : "false";
} else if (jval.isDouble()) {
value = QString::number(jval.toDouble());
value.setNum(jval.toDouble(), 'f', 0);
} else {
ok = false;
}
Expand Down