github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/configuration/functions/log.html.md (about)

     1  ---
     2  layout: "functions"
     3  page_title: "log - Functions - Configuration Language"
     4  sidebar_current: "docs-funcs-numeric-log"
     5  description: |-
     6    The log function returns the logarithm of a given number in a given base.
     7  ---
     8  
     9  # `log` Function
    10  
    11  -> **Note:** This page is about Terraform 0.12 and later. For Terraform 0.11 and
    12  earlier, see
    13  [0.11 Configuration Language: Interpolation Syntax](../../configuration-0-11/interpolation.html).
    14  
    15  `log` returns the logarithm of a given number in a given base.
    16  
    17  ```hcl
    18  log(number, base)
    19  ```
    20  
    21  ## Examples
    22  
    23  ```
    24  > log(50, 10)
    25  1.6989700043360185
    26  > log(16, 2)
    27  4
    28  ```
    29  
    30  `log` and `ceil` can be used together to find the minimum number of binary
    31  digits required to represent a given number of distinct values:
    32  
    33  ```
    34  > ceil(log(15, 2))
    35  4
    36  > ceil(log(16, 2))
    37  4
    38  > ceil(log(17, 2))
    39  5
    40  ```