Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. About a trouble with big numbers
Forum Update on Monday, May 27th 2025

About a trouble with big numbers

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 653 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.
  • M Offline
    M Offline
    mulfycrowh
    wrote on last edited by
    #1

    Hi !

    Everybody knows that 2 power 64 equals to 18446744073709551616 ...
    I defined a variable:

    quint64 x = 1 << 63;
    

    When I hover over x, VS2015 tells me: 18446744071562067968

    We agree that x equals to 2 power 63. So what VS gives is wrong.
    Could you help please ?
    Thanks.

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      remember that these are unsigned integers and constants are 32 bits by default and 1<<63 is 2^63 not 2^64 (easy to check that 1<<1 = 2^1 and 1<<2 = 2^2 and so on)

      quint64 x = 1Ui64 << 63;
      

      x == 9223372036854775808

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      2
      • M Offline
        M Offline
        mulfycrowh
        wrote on last edited by
        #3

        Ok, I forgot that ! Thanks a lot

        1 Reply Last reply
        0

        • Login

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