Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8281205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:57:02+00:00 2026-06-08T09:57:02+00:00

Code seems to skip the while loop: int i,j; i= floor((Lx-23.61)/0.1); j=0; while(Nh –

  • 0

Code seems to skip the while loop:

int i,j;
i= floor((Lx-23.61)/0.1);
j=0; 
while(Nh - modSED[i][j] > 0.0){
    j++;
}
if(j>0 && modSED[i][j]-Nh > Nh-modSED[i][j-1]){
    fileNH=modSED[i][j-1];
}else{
    fileNH=modSED[i][j];
}

It’s more or less a crude linear search through an array of doubles (the i-index is preset by another part of the code and shouldn’t be a problem). The code seems to misbehave when I look at GDB:

Breakpoint 1, mag (filter=4, Lx=23.930108812418158, z=0.57071772467724535, Nh=0.011911981460606383) at infopt.c:45
45      while(Nh-modSED[i][j]>0.0){
(gdb) print Nh-modSED[i][j]
$1 = 0.001911981460606383
(gdb) n
48      if(j>0 && modSED[i][j]-Nh > Nh-modSED[i][j-1]){
(gdb) 

and it has just skipped the j++ segment, even though the while loop should evaluate to true.

Thanks,
Josh

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T09:57:03+00:00Added an answer on June 8, 2026 at 9:57 am

    The external 2D array modSED was declared with the wrong dimensions (different from the c file in which it was initialized), so either the program, gdb, or both were confused. Fixing the dimensions of the declaration fixed the problem. (Here the problem refers to the larger issue that I wasn’t getting the correct value returned from modSED.) Since GDB seemed to give the wrong output, though, I was getting hung up on the wrong part of the code.

    Perhaps this in turn led to GDB seeming to defy logic and skip the while loop? (Running the program now, GDB has no trouble incrementing j and showing that it has done so.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code seems to work well, modifying the properties of my button, except the
The code seems not working. // $counter is an instance of Zend_Db_Table_Abstract $counter->update(array('hits' =>
My code seems to do infinite recursion when I invoke it with trees of
My code seems to run but it does not display the result any result
The following javascript code seems to leak memory but I’m not sure why. I’ve
The following code seems to be just too much, for getting a single count
The below code seems like it should work; however, the blob in the database
The following code seems not to work, even though the file appears to be
The following piece of code seems to unreliably execute and after and undeterministic time
Hey guys, the following snippet of jQuery code seems to work fine in Google

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.