-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cpp-qt-client] fix: Converting type double to QString uses scientific counting #20531
base: master
Are you sure you want to change the base?
Conversation
@wing328 Please help me to review this PR. |
thanks for the PR please follow step 3 to update the samples |
cc @ravinikam (2017/07) @stkrwork (2017/07) @etherealjoy (2018/02) @MartinDelille (2018/03) @muttleyxd (2019/08) |
please also update the description with more details on the issue this PR is trying to address. |
@wing328 I have modified it as required |
@@ -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); |
There was a problem hiding this comment.
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)
?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
.
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master
(upcoming7.x.0
minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)My interface returns an id value of '2660579988', which is then converted to scientific notation by this line of code, which in most cases requires raw strings, not scientific notation