It would almost certainly be a better implementation strategy to do three comparisons.
The limitation of array indexes to exact nonnegative integers only, and the requirement of starting at zero, is a problem that ought to be addressed first.