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. Algorithms
  4. Beginner Q: ^ = Math.Pow? (C#)

Beginner Q: ^ = Math.Pow? (C#)

Scheduled Pinned Locked Moved Algorithms
csharphelptutorialquestionlearning
6 Posts 5 Posters 4 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.
  • M Offline
    M Offline
    matthias s 0
    wrote on last edited by
    #1

    hi there, in my app i have to calculate a value using this syntax: x = 2^(y / 2) but ^ ist a logical operator in c#. what could be meant? how would i calculate x if, for example y = 4,33984375? or does ^ have a different meaning in this context (for example Math.Pow?). does anyone possibly understand what i'm after? any help is greatly appreciated.

    /matthias

    I love deadlines. I like the whooshing sound they make as they fly by.
    [Douglas Adams]

    C M P J 4 Replies Last reply
    0
    • M matthias s 0

      hi there, in my app i have to calculate a value using this syntax: x = 2^(y / 2) but ^ ist a logical operator in c#. what could be meant? how would i calculate x if, for example y = 4,33984375? or does ^ have a different meaning in this context (for example Math.Pow?). does anyone possibly understand what i'm after? any help is greatly appreciated.

      /matthias

      I love deadlines. I like the whooshing sound they make as they fly by.
      [Douglas Adams]

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

      matthias s. wrote:

      x = 2^(y / 2)

      To what context your expression belong? I mean, if it is a Visual Basic (VB6) one, then it translates to the following C# equivalent:

      x = Math.Pow(2, y / 2);

      On the other hand, if the context is C#, it simply doesn't make sense. :)

      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.

      1 Reply Last reply
      0
      • M matthias s 0

        hi there, in my app i have to calculate a value using this syntax: x = 2^(y / 2) but ^ ist a logical operator in c#. what could be meant? how would i calculate x if, for example y = 4,33984375? or does ^ have a different meaning in this context (for example Math.Pow?). does anyone possibly understand what i'm after? any help is greatly appreciated.

        /matthias

        I love deadlines. I like the whooshing sound they make as they fly by.
        [Douglas Adams]

        M Offline
        M Offline
        Manoj Kumar Rai
        wrote on last edited by
        #3

        Hi, Even I am not sure, what you want to achieve with that operator, but "^" is a logical exclusive - OR for binary type. Meaning the result will be true only if only one of the operand is true. "^" for the integral types (as above in your case) computes bitwise exclusive-OR of its operand. hence it will compare the each bit and apply exclusive-OR on each bits to find the last result.

        Manoj Never Gives up

        C 1 Reply Last reply
        0
        • M Manoj Kumar Rai

          Hi, Even I am not sure, what you want to achieve with that operator, but "^" is a logical exclusive - OR for binary type. Meaning the result will be true only if only one of the operand is true. "^" for the integral types (as above in your case) computes bitwise exclusive-OR of its operand. hence it will compare the each bit and apply exclusive-OR on each bits to find the last result.

          Manoj Never Gives up

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

          Manoj Kumar Rai wrote:

          but "^" is a logical exclusive - OR for binary type.

          Actually for single bits.:)

          Manoj Kumar Rai wrote:

          "^" for the integral types (as above in your case) computes bitwise exclusive-OR of its operand. hence it will compare the each bit and apply exclusive-OR on each bits to find the last result.

          He asked about doubles! :-D

          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.

          1 Reply Last reply
          0
          • M matthias s 0

            hi there, in my app i have to calculate a value using this syntax: x = 2^(y / 2) but ^ ist a logical operator in c#. what could be meant? how would i calculate x if, for example y = 4,33984375? or does ^ have a different meaning in this context (for example Math.Pow?). does anyone possibly understand what i'm after? any help is greatly appreciated.

            /matthias

            I love deadlines. I like the whooshing sound they make as they fly by.
            [Douglas Adams]

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            I expect that Math.Pow is what you want, but in some organizations you can get in trouble for thinking, so use the statement as told and shrug your shoulders when someone reports a bug.

            1 Reply Last reply
            0
            • M matthias s 0

              hi there, in my app i have to calculate a value using this syntax: x = 2^(y / 2) but ^ ist a logical operator in c#. what could be meant? how would i calculate x if, for example y = 4,33984375? or does ^ have a different meaning in this context (for example Math.Pow?). does anyone possibly understand what i'm after? any help is greatly appreciated.

              /matthias

              I love deadlines. I like the whooshing sound they make as they fly by.
              [Douglas Adams]

              J Offline
              J Offline
              Jeffrey Walton
              wrote on last edited by
              #6

              Hi Matthias, Try **. Just kidding :) Jeff

              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