Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Equation to predict highest number in a set

1436639959

Edited 1436640518
Axel
Pro
Sheet Author
Hi! I've got a set of 5 number variables from which I need to pick the highest one. I'd appreciate it if someone could help me out here.
If you're looking for a roll, you can do {a,b,c,d,e}kh1. If you want this in a calculated field, the max of two numbers is (a + b + abs(a - b)) / 2. You can iterate applying that formula to determine the max of more numbers because max(a, b, c) = max(max(a, b), c) = max(a, max(b, c)). Just be aware that it'll probably be a bit painful to extend it to five numbers.
1436650820
Axel
Pro
Sheet Author
Alright, thanks. If that's the only way of doing it, then I think I'll separate it into parts, like this: <input type="hidden" name="attr_A" value="(@{Stat1}+@{Stat2}+abs(@{Stat1}-@{Stat2}))/2" disabled="disabled"/> <input type="hidden" name="attr_B" value="(@{A}+@{Stat3}+abs(@{A}-@{Stat3}))/2" disabled="disabled"/> <input type="hidden" name="attr_C" value="(@{B}+@{Stat4}+abs(@{B}-@{Stat4}))/2" disabled="disabled"/> <input type="hidden" name="attr_D" value="(@{rC}+@{Stat5}+abs(@{C}-@{Stat5}))/2" disabled="disabled"/> That should solve it I think.