Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-85002

QString::toInt() should support the 0b prefix

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • P3: Somewhat important
    • 6.4.0 FF
    • 5.14.0, 5.14.2, 5.15.0, 6.2.4, 6.3.0
    • None
    • Fedora 32 Linux, CMake, QtCreator 4.12.2

    • All
    • 5
    • e48b4d2b7c1d99ba8962a9c10a1508d16dc33fbf
    • Team B Foundation Sprint 55, Team B Foundation Sprint 56

    Description

      Not certain whether this is a bug or intended but I noticed that when converting Hex/Octal/Binary strings to their int values I can convert hex using as either "0x64" or "64", Octal using either "0144" or "144", but Binary only using "1100100". If I use "0b1100100" I get a failure.

      QString t = "0b1100100";

      bool ok = false;

      int i;

      // t = t.mid(2);
      i = t.toInt(&ok, 2);

      gives i == 0 and ok == false. With the t=t.mid(2) to strip the Ob off if gives the correct value of 100 (decimal) and ok == true.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mmutz Marc Mutz
            simon.meaden Simon Meaden
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes