github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/configuration/functions/parseint.html.md (about) 1 --- 2 layout: "functions" 3 page_title: "parseint - Functions - Configuration Language" 4 sidebar_current: "docs-funcs-numeric-parseint" 5 description: |- 6 The parseint function parses the given string as a representation of an integer. 7 --- 8 9 # `parseint` 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 `parseint` parses the given string as a representation of an integer in 16 the specified base and returns the resulting number. The base must be between 2 17 and 62 inclusive. 18 19 All bases use the arabic numerals 0 through 9 first. Bases between 11 and 36 20 inclusive use case-insensitive latin letters to represent higher unit values. 21 Bases 37 and higher use lowercase latin letters and then uppercase latin 22 letters. 23 24 If the given string contains any non-digit characters or digit characters that 25 are too large for the given base then `parseint` will produce an error. 26 27 ## Examples 28 29 ``` 30 > parseint("100", 10) 31 100 32 33 > parseint("FF", 16) 34 255 35 36 > parseint("-10", 16) 37 -16 38 39 > parseint("1011111011101111", 2) 40 48879 41 42 > parseint("aA", 62) 43 656 44 45 > parseint("12", 2) 46 47 Error: Invalid function argument 48 49 Invalid value for "number" parameter: cannot parse "12" as a base 2 integer. 50 ``` 51 52 ## Related Functions 53 54 * [`format`](./format.html) can format numbers and other values into strings, 55 with optional zero padding, alignment, etc.