Author Topic: how can i get the answer in watches  (Read 6410 times)

Offline chaomengqing

  • Single posting newcomer
  • *
  • Posts: 4
  • does anyone who really pick up a star~~
how can i get the answer in watches
« on: July 03, 2008, 04:02:51 am »
hi~
when i debuging, the variable seems to be strange.
like the follow,
a=b+c+d;      //a,b,c,d are functions
i have break here to see the assignation of 'a', but i find that 'a' is different from 'b+c+d', as 'a' is 0.42 and 'b+c+d' is 1.09 in watches. Then i don't know which one is the right answer i'm looking for. Also 'a' is always changed when 'b''c''d' has been changed in next sentence.
Is there anything i should do before debuging?

Thank you if you can help me with that as i'm new with this software. :P

Offline Vuki

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: how can i get the answer in watches
« Reply #1 on: July 03, 2008, 07:30:05 am »
The program stops on the breakpoint before the marked line is executed. Press F7 - is the value of 'a' correct?. What you probably need is to set the breakpoint one line below to see the correct result.

Offline chaomengqing

  • Single posting newcomer
  • *
  • Posts: 4
  • does anyone who really pick up a star~~
Re: how can i get the answer in watches
« Reply #2 on: July 03, 2008, 09:29:35 am »
thank you for your answer.
i make the breakpoint at this sentence and press F7 to the next, then the value of 'a' in watches change but it seems to be wrong, it doesn't equal to 'b+c+d'. And with my pressing of F7, 'a' is ofen change, i don't know why.
sometimes it show that 'a=-nan(0x8000000000000)' when 'b+c+d' is definite.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: how can i get the answer in watches
« Reply #3 on: July 03, 2008, 09:40:26 am »
'a=-nan(0x8000000000000)' when 'b+c+d' is definite.
This is probably when a is not yet initialised and the calculation has not be done yet?!
Anyways - next time this happens please report the exact values and variable types of a, b, c and d to get a meaningful feedback. In the end the debugger is usually right so this most likely is not a problem with C::B.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline chaomengqing

  • Single posting newcomer
  • *
  • Posts: 4
  • does anyone who really pick up a star~~
Re: how can i get the answer in watches
« Reply #4 on: July 03, 2008, 09:55:36 am »
calculation has been done yet.

the sentence is like this:

square =1.5*(vx*vx + vy*vy );

the variable type of 'square''vx'and'vy' is register double, 'vx' and 'vy' have been evaluated before.
when i go to the next sentence'dot_g=-gx*vx-gy*vy;', the value are 'square=0', '1.5*(vx*vx + vy*vy )=0.015' in watch

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: how can i get the answer in watches
« Reply #5 on: July 03, 2008, 10:29:01 am »
when i go to the next sentence'dot_g=-gx*vx-gy*vy;', the value are 'square=0', '1.5*(vx*vx + vy*vy )=0.015' in watch
So it is working? I don't see a NAN anymore...?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline chaomengqing

  • Single posting newcomer
  • *
  • Posts: 4
  • does anyone who really pick up a star~~
Re: how can i get the answer in watches
« Reply #6 on: July 03, 2008, 10:42:38 am »
it works well till now after i change register double to double. :? orz
thank you