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

[Wiki] Arithmetic Reference

1458425446
Andrew C
Marketplace Creator
Is there a simple arithmetic reference? I'm looking for just a simple summary of the various arithmetic functions available, such as if there is a 'round down' or a 'standard shortcut for round down'? If there are functions like 'modulo' and so on. For a simple function I'd want to do is ((Stat)Modulo2 - 5) to try figure out things like modifier stats and so on.  Or to be able to say rounddown((Stat-10)/2).
1458426587
Diana P
Pro
Sheet Author
For rolls?&nbsp; <a href="https://wiki.roll20.net/Dice_Reference#Rounding_Ro" rel="nofollow">https://wiki.roll20.net/Dice_Reference#Rounding_Ro</a>... [[floor((stat-10)/2)]] and [[floor(stat/2)-5]] are/is (they give the same result) the most common way to figure out D&D ability bonuses.
1458430556
Andrew C
Marketplace Creator
Yeah, I was also thinking of things like the abs() function which has appeared, which can be used to calculate 'failed by n lots of k' type arithmetic. I suppose I'm just used to having more 'hard reference/glossaries' for things.
1458431566
Diana P
Pro
Sheet Author
*nod* Afaik, the only other reference we have to allowed math functions is a little up the same page : <a href="https://wiki.roll20.net/Dice_Reference#Including_A" rel="nofollow">https://wiki.roll20.net/Dice_Reference#Including_A</a>... where we can infer that + - * / and % are valid since you have to escape them if you want them in a description.&nbsp; (And I have used all of those in equations as well. :)&nbsp; There are several suggestions in the suggestions forum for additional math functions.&nbsp; In many cases these are particularly for use in the character sheet templates though the need for those has lessened a bit with sheet helpers since we can use the javascript math library.
1458440864

Edited 1458440992
Lithl
Pro
Sheet Author
API Scripter
I&nbsp; replicated the JavaScript Math library for autocalc functions on character sheets. Many of those calculations can be used in rolls as well, although any calculation which has to reference the same value more than one can't be used if your "value" is the result of a dice roll. (That said, rolls have access to some things autocalc fields don't. For example, max(x, y) requires referencing x and y once each which you couldn't use to get the max of two dice rolls, but rolls give you access to keep-high and keep-low which produce the same results as min and max, respectively. Autocalc fields cannot replicate random(), but dice rolls are &nbsp;random.) sign(x), trunc(x), and atan2(y, x) don't work for x=0 Of course, thanks to sheet worker scripts, that work isn't really necessary any more, but it's still there and may prove useful. =)