AnyDice

absolute NUMBER

This function yields the absolute value of the NUMBER. In other words, it discards the sign.

Examples

output [absolute -3]
output [absolute d6 - 3]
output [absolute d6 - d6]

Do it yourself

function: absolute NUMBER:n{
 if NUMBER < 0 { result: -NUMBER }
 result: NUMBER
}