github.com/iaas-resource-provision/iaas-rpc@v1.0.7-0.20211021023331-ed21f798c408/website/docs/language/functions/tonumber.html.md (about)

     1  ---
     2  layout: "language"
     3  page_title: "tonumber - Functions - Configuration Language"
     4  sidebar_current: "docs-funcs-conversion-tonumber"
     5  description: |-
     6    The tonumber function converts a value to a number.
     7  ---
     8  
     9  # `tonumber` Function
    10  
    11  `tonumber` converts its argument to a number value.
    12  
    13  Explicit type conversions are rarely necessary in Terraform because it will
    14  convert types automatically where required. Use the explicit type conversion
    15  functions only to normalize types returned in module outputs.
    16  
    17  Only numbers and strings containing decimal representations of numbers can be
    18  converted to number. All other values will produce an error.
    19  
    20  ## Examples
    21  
    22  ```
    23  > tonumber(1)
    24  1
    25  > tonumber("1")
    26  1
    27  > tonumber("no")
    28  Error: Invalid function argument
    29  
    30  Invalid value for "v" parameter: cannot convert "no" to number: string must be
    31  a decimal representation of a number.
    32  ```