Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Error with toULong() in Windows Qt 6.5.1
Qt 6.11 is out! See what's new in the release blog

Error with toULong() in Windows Qt 6.5.1

Scheduled Pinned Locked Moved Unsolved Qt 6
4 Posts 2 Posters 865 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anthony_NZ
    wrote on last edited by
    #1

    Hi Everyone.

    My first post, hopefully I am in the correct spot.

    bool ok;
    QString mStr = "FD17B9DD1653D9DF";
    quint64 tmp = mStr.toULong(&ok,16);

    This works in Linux ... ok = true, and tmp is the 64bit number representation of the hex characters.

    In windows 10 (x64) this fails - but if I use toULongLong it works.

    I was under the impression toULong should attempt to convert to a 64 bit unsigned integer in both Ubuntu x86_64 and Windows 10 (x64) or am I wrong?

    Ant

    Christian EhrlicherC 1 Reply Last reply
    0
    • A Anthony_NZ

      Hi Everyone.

      My first post, hopefully I am in the correct spot.

      bool ok;
      QString mStr = "FD17B9DD1653D9DF";
      quint64 tmp = mStr.toULong(&ok,16);

      This works in Linux ... ok = true, and tmp is the 64bit number representation of the hex characters.

      In windows 10 (x64) this fails - but if I use toULongLong it works.

      I was under the impression toULong should attempt to convert to a 64 bit unsigned integer in both Ubuntu x86_64 and Windows 10 (x64) or am I wrong?

      Ant

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by Christian Ehrlicher
      #2

      @Anthony_NZ said in Error with toULong() in Windows Qt 6.5.1:

      I was under the impression toULong should attempt to convert to a 64 bit unsigned integer in both Ubuntu x86_64 and Windows 10 (x64) or am I wrong?

      You're wrong and could have proven it by yourself easily:

      std::cout << "sizeof(ulong): " << sizeof(unsigned long) << "\n";
      std::cout << "sizeof(ulonglong): " << sizeof(unsigned long long) << "\n";
      

      Linux 64 bit:
      sizeof(ulong): 8
      sizeof(ulonglong): 8

      Windows 64bit:
      sizeof(ulong): 4
      sizeof(ulonglong): 8

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      A 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        @Anthony_NZ said in Error with toULong() in Windows Qt 6.5.1:

        I was under the impression toULong should attempt to convert to a 64 bit unsigned integer in both Ubuntu x86_64 and Windows 10 (x64) or am I wrong?

        You're wrong and could have proven it by yourself easily:

        std::cout << "sizeof(ulong): " << sizeof(unsigned long) << "\n";
        std::cout << "sizeof(ulonglong): " << sizeof(unsigned long long) << "\n";
        

        Linux 64 bit:
        sizeof(ulong): 8
        sizeof(ulonglong): 8

        Windows 64bit:
        sizeof(ulong): 4
        sizeof(ulonglong): 8

        A Offline
        A Offline
        Anthony_NZ
        wrote on last edited by
        #3

        @Christian-Ehrlicher

        Newbie error - thank you. I didn't appreciate Microsoft Windows backwards compatiblity if LP64 and LLP64 as I normally exclusively live on linux systems.

        Thank you!

        Christian EhrlicherC 1 Reply Last reply
        0
        • A Anthony_NZ

          @Christian-Ehrlicher

          Newbie error - thank you. I didn't appreciate Microsoft Windows backwards compatiblity if LP64 and LLP64 as I normally exclusively live on linux systems.

          Thank you!

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          That's why Qt introduced the qt fixed integer types by themself. the toULong() stuff is an relict from old Qt times and imho should have been replaced a long time ago with functions returning fixed integer types (or the qt fixed integer types).

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved