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. Problem using the "pow" function

Problem using the "pow" function

Scheduled Pinned Locked Moved C / C++ / MFC
help
5 Posts 2 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.
  • C Offline
    C Offline
    crushinghellhammer
    wrote on last edited by
    #1

    I have six lines in my code similar to the following: Biquad[0]->mfVh = pow(10, (0.05*mfGh)); On compiling the program I get the following error: error c2666: 'pow': 7 overloads have similar conversions. Could somebody explain to me what this means. Biquad[i] is an object of cBiquad. mfVh and mfGh are floats. I've tried suffixing 10 and 0.05 with f, but that gives me a separate error saying that the use of the suffix there is incorrect. If you could let me know what I'm doing wrong it would be of great help! Thanks!

    C 1 Reply Last reply
    0
    • C crushinghellhammer

      I have six lines in my code similar to the following: Biquad[0]->mfVh = pow(10, (0.05*mfGh)); On compiling the program I get the following error: error c2666: 'pow': 7 overloads have similar conversions. Could somebody explain to me what this means. Biquad[i] is an object of cBiquad. mfVh and mfGh are floats. I've tried suffixing 10 and 0.05 with f, but that gives me a separate error saying that the use of the suffix there is incorrect. If you could let me know what I'm doing wrong it would be of great help! Thanks!

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

      I seem to have fixed it by some kind of brute casting technique. The line now reads: Biquad[0]->mfVh = pow((float)10, (float)(0.05*mfGh)); Here's a link to the MSDN document if somebody else has a similar problem ERROR C2666 Suggestions for more elegant solutions are welcome!

      L 1 Reply Last reply
      0
      • C crushinghellhammer

        I seem to have fixed it by some kind of brute casting technique. The line now reads: Biquad[0]->mfVh = pow((float)10, (float)(0.05*mfGh)); Here's a link to the MSDN document if somebody else has a similar problem ERROR C2666 Suggestions for more elegant solutions are welcome!

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        I had the same problem. Are you using VS2003? It doesnt seem to be a problem in vs6 Change your code like this. Its a bit neater Biquad[0]->mfVh = ::pow(10.0, 0.05*mfGh);

        C 1 Reply Last reply
        0
        • L Lost User

          I had the same problem. Are you using VS2003? It doesnt seem to be a problem in vs6 Change your code like this. Its a bit neater Biquad[0]->mfVh = ::pow(10.0, 0.05*mfGh);

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

          Josh, Thanks for the tip, and yes, I'm using VS2003. That's a really weird error...digging through the MSDN documentation helped a little and I typecasted everything that could be (even the result, but apparently that wasn't required). I like your solution better. Could you please explain what the "::" does? Thanks again!

          L 1 Reply Last reply
          0
          • C crushinghellhammer

            Josh, Thanks for the tip, and yes, I'm using VS2003. That's a really weird error...digging through the MSDN documentation helped a little and I typecasted everything that could be (even the result, but apparently that wasn't required). I like your solution better. Could you please explain what the "::" does? Thanks again!

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            The :: means "the pow() function from the globalname space". This is redundant if you dont use namespaces, and probably if you do but I like to use it when calling functions from the c library as it makes the code a bit easier to read im my opinion. Look at the declaration of the pow() template function in math.h if you are still unsure about how to use it

            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