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. C / C++ / MFC
  3. 4*4*4*4=?

4*4*4*4=?

Scheduled Pinned Locked Moved C / C++ / MFC
4 Posts 4 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi I have a very little problem, but still it is a problem so please if you know any solution write me back. How do you write this 2^4 in C++? When I write it in the program the compiler, compiles it as 2+4=6 when it should be 2*2*2*2. thanks!

    N T M 3 Replies Last reply
    0
    • L Lost User

      Hi I have a very little problem, but still it is a problem so please if you know any solution write me back. How do you write this 2^4 in C++? When I write it in the program the compiler, compiles it as 2+4=6 when it should be 2*2*2*2. thanks!

      N Offline
      N Offline
      NullStream
      wrote on last edited by
      #2

      2^4 = 0010 ^ 0100 = 0110 = 6 which would explain why you are getting 6 as a result. I would suggest using the following function located in math.h double pow( double x, double y ); Sean Cody

      1 Reply Last reply
      0
      • L Lost User

        Hi I have a very little problem, but still it is a problem so please if you know any solution write me back. How do you write this 2^4 in C++? When I write it in the program the compiler, compiles it as 2+4=6 when it should be 2*2*2*2. thanks!

        T Offline
        T Offline
        Tim Smith
        wrote on last edited by
        #3

        There isn't an exponential operator in C. However, you do have the pow function. Sort of sucks... Tim Smith Descartes Systems Sciences, Inc.

        1 Reply Last reply
        0
        • L Lost User

          Hi I have a very little problem, but still it is a problem so please if you know any solution write me back. How do you write this 2^4 in C++? When I write it in the program the compiler, compiles it as 2+4=6 when it should be 2*2*2*2. thanks!

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          ^ is the XOR operator in C. :) As others have said there is no raise-to-power operator. --Mike-- "Everyone has figured out what 'service pack' really means, so they had to go and change the language. Perhaps this is what Bill was talking about in the 'security is top priority' letter."   -- Daniel Ferguson, 1/31/2002 My really out-of-date homepage Sonork - 100.10414 AcidHelm Big fan of Alyson Hannigan.

          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