Re: Loop doesn't behave the way it's supposed to.
From: Joona I Palaste (palaste_at_cc.helsinki.fi)
Date: 01/03/04
- Next message: Malcolm: "BASIC advice wanted."
- Previous message: Stephan Aspridis: "Loop doesn't behave the way it's supposed to."
- In reply to: Stephan Aspridis: "Loop doesn't behave the way it's supposed to."
- Next in thread: Peter Pichler: "Re: Loop doesn't behave the way it's supposed to."
- Reply: Peter Pichler: "Re: Loop doesn't behave the way it's supposed to."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 3 Jan 2004 21:09:50 GMT
Stephan Aspridis <s.aspridis@t-online.de> scribbled the following:
> Hi folks,
> a happy new year. I have a little problem with a program I am writing at
> the moment. A loop doesn't behave the way I'd like to (namely, the
> "break" is ignored). This is the code in question:
> ----------------------------------
> star[s].planet[0].orbit_distance =
> pow(SOLDENSITY/EARTHDENSITY,1.0/3.0)*sqrt(star[s].mass)*get_random(50.0,150.0)/100.0;
> for (p=0;p<orbcount-1;p++){
> x = p+1;
> star[s].planet[x].orbit_distance =
> star[s].planet[p].orbit_distance*get_random(1250.0,2500.0)/1000.0;
> if (star[s].planet[p].orbit_distance>star[s].orbit_limit)
> break;
Probably stupid question, since I was too lazy to work out the
mathematical algorithm, but are you sure it isn't because you are
assigning to star[s].planet[x].orbit_distance, but comparing
star[s].planet[p].orbit_distance? Those are two different variables.
> }//end for
> star[s].number_of_orbits = p;
> ----------------------------------
-- /-- Joona Palaste (palaste@cc.helsinki.fi) ------------- Finland --------\ \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/ "Stronger, no. More seductive, cunning, crunchier the Dark Side is." - Mika P. Nieminen
- Next message: Malcolm: "BASIC advice wanted."
- Previous message: Stephan Aspridis: "Loop doesn't behave the way it's supposed to."
- In reply to: Stephan Aspridis: "Loop doesn't behave the way it's supposed to."
- Next in thread: Peter Pichler: "Re: Loop doesn't behave the way it's supposed to."
- Reply: Peter Pichler: "Re: Loop doesn't behave the way it's supposed to."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|