Skip to content

Fix math in static example code #226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Language/Variables/Variable Scope & Qualifiers/static.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ int randomWalk(int moveSize){

place = place + (random(-moveSize, moveSize + 1));

if (place < randomWalkLowRange){ // check lower and upper limits
place = place + (randomWalkLowRange - place); // reflect number back in positive direction
if (place < randomWalkLowRange){ // check lower and upper limits
place = randomWalkLowRange + (randomWalkLowRange - place); // reflect number back in positive direction
}
else if(place > randomWalkHighRange){
place = place - (place - randomWalkHighRange); // reflect number back in negative direction
place = randomWalkHighRange - (place - randomWalkHighRange); // reflect number back in negative direction
}

return place;
Expand Down