The log2()
function in
Figure 1 below shows the mathematical representation of the log2()
function.
log2(number);
This function requires a number
whose logarithm base 2 must be calculated at greater than zero.
If the number is zero
, then this function outputs -Inf
.
If the number is negative
, then this function outputs NaN
along with a warning message.
log2()
returns the logarithm of a number to the base 2.
a <- log2(10);print(paste0("log2(10): ", a))b <- log2(2);print(paste0("log2(2): ", b))c <- log2(15.2);print(paste0("log2(15.2): ", c))#error outputsd <- log2(0);print(paste0("log2(0): ", d))e <- log2(-1);print(paste0("log2(-1): ", e))