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...

P#13499 2015-09-01 13:42 ( Edited 2015-09-01 23:19)

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.

P#13502 2015-09-01 13:53 ( Edited 2015-09-01 17:53)

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

P#13524 2015-09-01 19:19 ( Edited 2015-09-01 23:19)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2023-03-27 06:46:39 | 0.005s | Q:9