Eric Y.

asked • 10/05/18# How do I express that a value needs to be between two separate values (a minimum and a maximum), but should be used as is if it does fall within those limits?

More specifically, I currently have it written as X ≤ Y ≤ Z, but I want to also specify that Y is the default while X and Z only come into effect if Y falls outside of their limit. Or, if more information is needed, this is the formula I have as it currently stands:

Hit rate = ((1 + Attacker's Luk / 25) / 150) ≤ ((1 - (0 ≤ ((Defender's Melee or Pierce or Magic - Attacker's Bonus) / 150) ≤ 1)) * (1 - (0 ≤ ((Defender's Block or Parry or Dodge - Attacker's Bonus) / 150 * (1 - Attacker's Crit / 200)) ≤ 1))) ≤ 0.9933

(Defender's Melee or Pierce or Magic - Attacker's Bonus) / 150) for example needs to be ≤ 1 and ≥ 0 because it's a chance between 0 and 100%, and the final value should be solved down to X ≤ Y ≤ 0.9933, where Y is the final chance to successfully hit and should be the value used unless X is higher or 0.9933 is lower.

More

## 1 Expert Answer

Why not use the average?

if x < y < z then

return Y

else

return (x+z)/2

## Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.

Most questions answered within 4 hours.

#### OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.

Mark M.

10/05/18