Skip to content
drewmccluskey edited this page Jan 14, 2019 · 7 revisions

log2

This function returns the log base 2 of n

Syntax:

log2(n)
Argument Description
double n The input value

Returns: double

Description:

The function asks: "How many times does the number 2 have to be multiplied by itself to equal n?" For example, function log2(4) will return 2, because 2x2 = 4. There are 2 powers of 2 to equal 4.

Example:

double value;
value = log2(16);

This code will set value to 4, beacuse 2x2x2x2 = 16. There are 4 powers of 2 to equal 16.

Example 2:

double value;
value = log2(5);

This code will set value to 2.321929.

Back to number_functions

Clone this wiki locally