Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Constants optimization

Constants optimization

Scheduled Pinned Locked Moved C / C++ / MFC
algorithmsperformancequestion
5 Posts 3 Posters 0 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.
  • H Offline
    H Offline
    hint_54
    wrote on last edited by
    #1

    Hi all =) An easy one. I'm just not sure the compiler does this the way I think it does... The following expression would be evaluted to a constant, right? (tOC(1) << (sizeof(T) << 3)) - 1 Lets say that, when compiled, the code will no longer be an expression, but a constant value. But what about this? oc & ((tOC(1) << (sizeof(T) << 3)) - 1) Evaluates to: oc & const Is this right? Best regards

    C N 2 Replies Last reply
    0
    • H hint_54

      Hi all =) An easy one. I'm just not sure the compiler does this the way I think it does... The following expression would be evaluted to a constant, right? (tOC(1) << (sizeof(T) << 3)) - 1 Lets say that, when compiled, the code will no longer be an expression, but a constant value. But what about this? oc & ((tOC(1) << (sizeof(T) << 3)) - 1) Evaluates to: oc & const Is this right? Best regards

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      hint_54 wrote:

      tOC(1)

      :confused:

      hint_54 wrote:

      oc

      :confused: ????

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

      H 1 Reply Last reply
      0
      • C CPallini

        hint_54 wrote:

        tOC(1)

        :confused:

        hint_54 wrote:

        oc

        :confused: ????

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

        H Offline
        H Offline
        hint_54
        wrote on last edited by
        #3

        There's a line before that :P tOC oc; tOC is the datatype, I'm just casting ;) regards

        1 Reply Last reply
        0
        • H hint_54

          Hi all =) An easy one. I'm just not sure the compiler does this the way I think it does... The following expression would be evaluted to a constant, right? (tOC(1) << (sizeof(T) << 3)) - 1 Lets say that, when compiled, the code will no longer be an expression, but a constant value. But what about this? oc & ((tOC(1) << (sizeof(T) << 3)) - 1) Evaluates to: oc & const Is this right? Best regards

          N Offline
          N Offline
          Nelek
          wrote on last edited by
          #4

          Take a look into the last sentence in my signature

          Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson

          H 1 Reply Last reply
          0
          • N Nelek

            Take a look into the last sentence in my signature

            Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson

            H Offline
            H Offline
            hint_54
            wrote on last edited by
            #5

            I totally disagree =) Otherwise, how would I learn? ;) best regards

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups