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. pow function appears to fail randomly.

pow function appears to fail randomly.

Scheduled Pinned Locked Moved C / C++ / MFC
helphardwaredebuggingquestion
11 Posts 6 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.
  • M Member 2088

    This my program int _tmain(int argc, _TCHAR* argv[]) { int a=0; double b=10; double result = pow(b,a); double r=0; for(int aa=0;aa<30000;aa++) { for(int i=0; i<30000;i++) { for(int j=0; j<30000;j++) { r = pow(b,a); if(r != result) { int error =0; } } } } return 0; } I put a breakpoint on the int error = 0. It got hit when aa=0,i=19383,j= 26848. Could this be a hardware problem or something else? Running VS2008 with latest service packs.

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

    Member 2088 wrote:

    I put a breakpoint on the int error = 0. It got hit when aa=0,i=19383,j= 26848.

    What were the values of r and result at the time of failure?

    M 1 Reply Last reply
    0
    • M Member 2088

      This my program int _tmain(int argc, _TCHAR* argv[]) { int a=0; double b=10; double result = pow(b,a); double r=0; for(int aa=0;aa<30000;aa++) { for(int i=0; i<30000;i++) { for(int j=0; j<30000;j++) { r = pow(b,a); if(r != result) { int error =0; } } } } return 0; } I put a breakpoint on the int error = 0. It got hit when aa=0,i=19383,j= 26848. Could this be a hardware problem or something else? Running VS2008 with latest service packs.

      D Offline
      D Offline
      dxlee
      wrote on last edited by
      #3

      Your program ran without a problem on my system. It never reached the break point.

      1 Reply Last reply
      0
      • L Lost User

        Member 2088 wrote:

        I put a breakpoint on the int error = 0. It got hit when aa=0,i=19383,j= 26848.

        What were the values of r and result at the time of failure?

        M Offline
        M Offline
        Member 2088
        wrote on last edited by
        #4

        When it hit the error line r = -1.#IND000000000000 a and b are correct.

        L 1 Reply Last reply
        0
        • M Member 2088

          When it hit the error line r = -1.#IND000000000000 a and b are correct.

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

          Member 2088 wrote:

          When it hit the error line r = -1.#IND000000000000 a and b are correct.

          So what were the values? Also I asked what the value of result was.

          M 1 Reply Last reply
          0
          • L Lost User

            Member 2088 wrote:

            When it hit the error line r = -1.#IND000000000000 a and b are correct.

            So what were the values? Also I asked what the value of result was.

            M Offline
            M Offline
            Member 2088
            wrote on last edited by
            #6

            b=10.000000000000000 a = 0 result = 1.0000000000000000

            J 1 Reply Last reply
            0
            • M Member 2088

              b=10.000000000000000 a = 0 result = 1.0000000000000000

              J Offline
              J Offline
              josda1000
              wrote on last edited by
              #7

              Is this really the intent of the program, to never change "a" or "b"? because in this case, you'll always get a result of 1. So you'll be going in a double-nested loop for a long time to just get a result of 1...

              M 1 Reply Last reply
              0
              • M Member 2088

                This my program int _tmain(int argc, _TCHAR* argv[]) { int a=0; double b=10; double result = pow(b,a); double r=0; for(int aa=0;aa<30000;aa++) { for(int i=0; i<30000;i++) { for(int j=0; j<30000;j++) { r = pow(b,a); if(r != result) { int error =0; } } } } return 0; } I put a breakpoint on the int error = 0. It got hit when aa=0,i=19383,j= 26848. Could this be a hardware problem or something else? Running VS2008 with latest service packs.

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #8

                Member 2088 wrote:

                double b=10; double result = pow(b,a); double r=0;

                What happens if you did:

                double b = 10.0;
                double r = 0.0;

                "One man's wage rise is another man's price increase." - Harold Wilson

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                1 Reply Last reply
                0
                • J josda1000

                  Is this really the intent of the program, to never change "a" or "b"? because in this case, you'll always get a result of 1. So you'll be going in a double-nested loop for a long time to just get a result of 1...

                  M Offline
                  M Offline
                  Member 2088
                  wrote on last edited by
                  #9

                  The point is to demonstrate the 'random' failure.

                  L 1 Reply Last reply
                  0
                  • M Member 2088

                    This my program int _tmain(int argc, _TCHAR* argv[]) { int a=0; double b=10; double result = pow(b,a); double r=0; for(int aa=0;aa<30000;aa++) { for(int i=0; i<30000;i++) { for(int j=0; j<30000;j++) { r = pow(b,a); if(r != result) { int error =0; } } } } return 0; } I put a breakpoint on the int error = 0. It got hit when aa=0,i=19383,j= 26848. Could this be a hardware problem or something else? Running VS2008 with latest service packs.

                    T Offline
                    T Offline
                    T2102
                    wrote on last edited by
                    #10

                    Are you only running the block of code above or is it part of a larger program? Taking over a buggy program in the past, I have had programs that malfunction when a variable name was changed from x to y. This was the result of memory errors that I had to track down and fix.

                    1 Reply Last reply
                    0
                    • M Member 2088

                      The point is to demonstrate the 'random' failure.

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

                      The value -1.#IND indicates a number that cannot be represented (IND = indeterminate) and will be caused by a floating point error. This could well be a hardware problem but it is impossible to be certain.

                      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