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. Cast (int)qint64 ??
Forum Updated to NodeBB v4.3 + New Features

Cast (int)qint64 ??

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 9.2k Views 1 Watching
  • 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.
  • I Offline
    I Offline
    inspired
    wrote on last edited by
    #1

    i have a qint64 var1 = 1345830775404
    and int var2 = (int)var1; (var2 becomes 1506011756, what gives?)

    To clarify what i am trying to do is to get in an integer the seconds since 1970 January 1st
    in an application online it returns 1345830763 seconds.
    so it seems is just have to "cut off" the last 3 digits..
    ideas?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      rcari
      wrote on last edited by
      #2

      qint64 is 64 bits wide, it can store 2^32 times more values than an int (which is 32 bits wide). If you want to operate on UNIX timestamps based on the epoch, you HAVE to use at least a 64 bits integer, because they will most likely not fit in 32 bits.

      1 Reply Last reply
      0
      • I Offline
        I Offline
        inspired
        wrote on last edited by
        #3

        oops just figured that i was using milliseconds instead of seconds :/ (sorry about that :$ )
        so this just did it
        @int secSince1970 = QDateTime::currentDateTimeUtc().toMSecsSinceEpoch()/1000;@

        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