./redteamer

Functions

Numeric Functions

Functions for the creation and manipulation of numbers.


Basic Arithmetic

sum

The sum function adds together a list or set of numbers.

The syntax for the num::sum function is as follows:

num::sum(numbers)

Here, numbers refers to the list or set that you want to sum up.

To better understand how the sum function works, let's look at an example:

Suppose we have the following list of numbers:

[8, 15, 7, 3.2]

We can use the sum function to add up these numbers as follows:

num::sum([8, 15, 7, 3.2])

This will return 33.2, which is the sum of the numbers in the list.

max

The num::max function accepts one or more numbers and delivers the largest number from the set.

num::max(22, 45, 9) // returns 45

If the numbers are part of a list or set value, use ... to expand the collection into individual arguments:

num::max([22, 45, 9]...) // returns 45

min

The num::min function takes one or more numbers and returns the smallest number from the set.

num::min(22, 45, 9) // returns 9

If the numbers are in a list or set value, use ... to expand the collection to individual arguments:

num::min([22, 45, 9]...) // returns 9

Rounding and Absolute Value

abs

The num::abs function gives you the absolute value of a provided number. Essentially, if the number is zero or positive, it returns the number as is. However, if the number is negative, it multiplies it by -1 to convert it into a positive number before returning it.

num::abs(18)    // returns 18
num::abs(0)     // returns 0
num::abs(-7.5)  // returns 7.5

ceil

The num::ceil function rounds up the given value to the nearest whole number that is equal to or greater than the value, even when the value is a fraction.

num::ceil(3)   // returns 3
num::ceil(3.7) // returns 4

Exponential and Logarithmic

pow

The num::pow function computes an exponent by raising its first argument to the power of the second argument.

num::pow(2, 3) // returns 8
num::pow(5, 0) // returns 1

log

The num::log function calculates the logarithm of a given number based on a specified base.

num::log(number, base)
num::log(100, 10) // returns 2
num::log(32, 2)   // returns 5

By combining num::log and num::ceil, you can determine the minimum number of binary digits needed to represent a specific number of distinct values:

num::ceil(num::log(31, 2)) // returns 5
num::ceil(num::log(32, 2)) // returns 5
num::ceil(num::log(33, 2)) // returns 6

Sign

signum

The num::signum function evaluates the sign of a number, returning a number between -1 and 1 to symbolize the sign.

num::signum(-25) // returns -1
num::signum(0)   // returns 0
num::signum(150) // returns 1
Previous
Network Functions