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