code/__DEFINES/math.dm 
| SIGN | Gets the sign of x, returns -1 if negative, 0 if 0, 1 if positive |
|---|---|
| WRAP_UP | Increments a value and wraps it if it exceeds some value. Can be used to circularly iterate through a list through idx = WRAP_UP(idx, length_of_list). |
| TOBITSHIFT | Gets shift x that would be required the bitflag (1<<x) We need the round because log has floating-point inaccuracy, and if we undershoot at all on list indexing we'll get the wrong index. |
| SPT_PROB_RATE | Converts a probability/second chance to probability/seconds_per_tick chance
For example, if you want an event to happen with a 10% per second chance, but your proc only runs every 5 seconds, do if(prob(100*SPT_PROB_RATE(0.1, 5))) |
| SPT_PROB | Like SPT_PROB_RATE but easier to use, simply put if(SPT_PROB(10, 5)) |
| DIAMOND_AREA | The number of cells in a taxicab circle (rasterized diamond) of radius X. |
| randfloat | rand() but for floats, returns a random floating point number between L and H |
| IS_IN_BOUNDS | Tests if the value is in the given range. |
Define Details
DIAMOND_AREA 
The number of cells in a taxicab circle (rasterized diamond) of radius X.
IS_IN_BOUNDS 
Tests if the value is in the given range.
SIGN 
Gets the sign of x, returns -1 if negative, 0 if 0, 1 if positive
SPT_PROB 
Like SPT_PROB_RATE but easier to use, simply put if(SPT_PROB(10, 5))
SPT_PROB_RATE 
Converts a probability/second chance to probability/seconds_per_tick chance
For example, if you want an event to happen with a 10% per second chance, but your proc only runs every 5 seconds, do if(prob(100*SPT_PROB_RATE(0.1, 5)))
TOBITSHIFT 
Gets shift x that would be required the bitflag (1<<x) We need the round because log has floating-point inaccuracy, and if we undershoot at all on list indexing we'll get the wrong index.
WRAP_UP 
Increments a value and wraps it if it exceeds some value. Can be used to circularly iterate through a list through idx = WRAP_UP(idx, length_of_list).
randfloat 
rand() but for floats, returns a random floating point number between L and H