Missing zero in exponential format



  • Since our upgrade from qt 5.3.1 to 5.7.0 it seems that the output of the exponential format is missing the leading zero:

    Using the code below:
    double testValue = 1234.5678;
    QString (" <Value>%1</value>\n").arg (testValue, 0, 'E', 2);

    I expect:
    <Value>1.23E+03</value>
    but get:
    <Value>1.23E+3</value>

    Has anyone a clue how this could be solved?

    Regards,

    Marcel


  • Moderators

    Hi,

    @EMStegehuis said in Missing zero in exponential format:

    Since our upgrade from qt 5.3.1 to 5.7.0 it seems that the output of the exponential format is missing the leading zero:

    Using the code below:
    double testValue = 1234.5678;
    QString (" <Value>%1</value>\n").arg (testValue, 0, 'E', 2);

    I expect:
    <Value>1.23E+03</value>
    but get:
    <Value>1.23E+3</value>

    Has anyone a clue how this could be solved?

    I can reproduce this.

    • Qt 5.4.2 (MSVC2013 32-bit) produces "<Value>1.23E+03</value>"
    • Qt 5.8.0 (MinGW 5.3.0) produces "<Value>1.23E+3</value>"

    It looks like the behaviour has changed between versions. I'm not sure if this was intentional or not.

    Would you be willing to raise this at the Interest mailing list? (http://lists.qt-project.org/mailman/listinfo/interest ) -- subscribe and then post there. Qt's engineers are active on that list.



  • Thiago Macieira responded to the request on the mailing list. It most likely has its origin in a change to using the double conversion library as of QT 5.7 over sprintf.

    See: http://lists.qt-project.org/pipermail/interest/2017-March/026409.html

    Thanks for the responses.

    Marcel


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.