CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Testing for -nan (in the debugger)

    We all know that when setting breakpoints we can specify a condition - for example it can be specified to stop only when a value is zero. Here's some code that's causing a problem for me:-

    Code:
    double
    HighFrequencyAudioCurve::processDouble(const double *R__ mag, int increment)
    {
        double result = 0.0;
    
        const int sz = m_lastPerceivedBin;
    
        for (int n = 0; n <= sz; ++n) {
            result = result + mag[n] * n; // <--- 'result' ends up as -nan
        }
    
        return result;
    }
    After going around the loop several hundred times, result ends up as -nan - but unfortunately, -nan isn't accepted as a condition for a breakpoint. VS gives me this dialog at runtime:-

    Name:  Capture.png
Views: 108
Size:  40.5 KB

    Can anyone suggest some way to test for -nan ?
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  2. #2
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: Testing for -nan (in the debugger)

    It's okay - I solved it by calling isnan() and placing a breakpoint if the return value was non-zero.

    BTW - does anyone know what the statement double *R__ mag means..? I've never come across R__ before

    [Edit...] If it helps, I just found that R__ is a #define saying #define R__ __restrict
    Last edited by John E; February 16th, 2022 at 07:04 AM.
    "A problem well stated is a problem half solved.” - Charles F. Kettering

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured