Parse Int

Description

This operation parses a string and returns an integer of the specified base (or radix).

In a positional numeral system, the base is the number of unique digits, including the digit zero, used to represent numbers. For example, for the decimal system, the radix is ten, because it uses the ten digits from 0 through 9.

In any standard positional numeral system, a number is conventionally written as (x)y with x as the string of digits and y as its base. However, for base ten the subscript is usually assumed (and omitted, together with the pair of parentheses), as it is the most common way to express value. For example, (100)10 is equivalent to 100 (the decimal system is implied in the latter) and represents the number one hundred, while (100)2 (in the binary system with base 2) represents the number four.

Commonly used numeral systems include:

  • 2 - Binary numeral system

  • 8 - Octal system

  • 10 - Decimal system

  • 12 - Duodecimal (dozenal) system

  • 16 - Hexadecimal system

  • 20 - Vigesimal system

  • 36 - Base36

  • 60 - Sexagesimal system


Data types

These are the input/output expected data types for this operation:

Input data

Output data


Parameters

These are the parameters you need to configure to use this operation (mandatory parameters are marked with a *):

Base*

An integer between 2 and 36 that represents the string's base.

If it's nonzero and outside the range 2-36, the operation will always fail.

If the base argument is 0, the true base is implied by the string's prefix with leading whitespace and possible +/- signs removed:

  • 2 for 0b.

  • 8 for 0 or 0o.

  • 16 for 0x.

  • and 10 otherwise.

For example, if your string is 0b100 and you enter 0 as Base, the operation will assume that the true base is 2.


Example

Suppose you want to parse a series of strings and convert them to integers according to a specific base:

  1. In your Pipeline, open the required Action configuration and select the input Field.

  2. In the Operation field, choose Parse int.

  3. Set Base to 2.

  4. Give your Output field a name and click Save. The strings in your input field will be parsed according to the specified base. In this example:

100(2) -> 4

You can try out operations with specific values using the Input field above the operation. You can enter the value in the example above and check the result in the Output field.

Last updated