Log In  


This code:

sprinklerx = mid(sprinklermaxx+1,sprinklerminx-1,sprinklerx)

is not equal to this:

  if (sprinklerx>sprinklermaxx) sprinklerx = sprinklermaxx
  if (sprinklerx<sprinklerminx) sprinklerx = sprinklerminx

Bug or what?

//edit: To elaborate, MID version always returns sprinklermaxx+1 for some reason, even if sprinklerx is 1. If we only had better debugging, like stepthrough, breakpoints...



The mid function assumes that the 1st argument is the lower bound, and the 3rd argument is the higher bound. I'll admit that this behavior isn't exactly what it says on the tin, and it should probably called something like "clamp" or fixed to work any way.


MID has a bug when the first argument is the largest one. Always put the smallest one first.



[Please log in to post a comment]