# Is Between Angles Returns False; Value=Upper Bound

• Problem Description

"Is Between Angles" does not return true if the value is equal to the upper bound.

Attach a Capx

https://www.dropbox.com/s/ipe8nen5g6ozq0s/Is%20Between%20Bug.capx?dl=0

Description of Capx

There are four text boxes.

The first two use the "Is Between Values" condition, if(0<=0/10<=10){Set Text}

The first two use the "Is Between Angles" condition, if(0<=0/10<=10){Set Text}

Steps to Reproduce Bug

Compare upper bound value in "Is Between Angles"

Observed Result

Setting the value to the upper bound of "Is Between Angles" does not return true.

Expected Result

The same result as "Is Between Values"

Construct 2 Version ID

r244

• This is currently by design. The top end is currently exclusive, so it's essentially doing the comparison lower <= n < upper. This is because otherwise adjacent ranges become overlapping. For example suppose you have:

Is between 0 and 90 degrees: do A

Is between 90 and 180 degrees: do B

It seems reasonable to expect that it would only ever do A or B. However if we make the range inclusive, it becomes possible for both conditions to be true at the same time, when at exactly 90 degrees. This may be a bit of a surprise, and is also tricky to work around: you have to make the second condition "is between 90 + tiny amount and 180 degrees". Then there's a possible secondary bug where if the object is pointing just in between 90 and 90 + tiny amount (which is easily possible with floating point precision, e.g. doing a calculation that results in 90.0000000000000001 degrees), then neither condition is true, which is even more confusing.

So I don't think this should be changed. It would also be a non-backwards-compatible change, which could break projects. Perhaps we could add an extra parameter to make it an inclusive check.

• Ah! Haha there have been a few on another topic that were quite confused as to why this was set up the way it was, but explaining it that way makes a lot of sense.

If it'd be easier you could just add to the manual to state that the upper bound is exclusive. That way if anyone ran into the issue they'd simply have to check the manual.