What is an Integer?

You are currently viewing What is an Integer?

Overview

An Integer can be defined as a whole number. Integers can be positive, negative, or even zero. For example, 3, -5, 0, and even 2,424,323,634 are all Integers. Integers can’t contain decimal points or fractions and therefore will be rounded to the nearest whole number.

In UiPath, there is not one specific Integer data type and is broken out into three main data types. The only difference between these three data types is the number value that can be stored. Each data type has a different range of values and are determined based on the memory allocated (16, 32, or 64 bits).

  • Int16 – Can only hold values between -32,768 and +32,767
  • Int32 – Can only hold values between -2,147,483,648 and +2,147,483.
  • Int64 – Can only hold values between -9,223,372,036,854,775,808 and +9,223,372,036,854,775,808

The most popular Integer data type used in UiPath is the Int32 as it strikes a good balance between storage and memory size.

What can you do with Integers?

Below or some great examples of the use of Integers:

  • Performing Mathematical Calculations
  • Counting for Loops
  • Keeping track of transaction numbers

Commonly Used Properties

Below are some commonly used properties for Integers. A property is a characteristic or attribute of an object (i.e. Integers). To learn more about properties, click here

MaxValue - Returns the largest value for an integer

Example Property Example Return Return Type
Int16.MaxValue
32767
Integer (Int16)
Int32.MaxValue
2147483
Integer (Int32)
Int64.MaxValue
9223372036854775808
Integer (Int64)

MinValue - Returns the smallest value for an integer

Example Property Example Return Return Type
Int16.MinValue
-32767
Integer (Int16)
Int32.MinValue
-2147483
Integer (Int32)
Int64.MinValue
-9223372036854775808
Integer (Int64)

Commonly Used Methods

Below or some commonly used methods for integers. Methods are actions that objects (i.e. Integers) can perform. To learn more about methods, click here.

For all examples below, we will be using the following Int32 variable, intVar, which has been assigned as 108.

CompareTo(Integer) - Compares 2 Integers and returns 1 if it is greater than the comparing integer, 0 if they match, or -1 if it is less than the comparing integer

Example Method Example Return Return Type
22.CompareTo(10)
-1
Integer (Int32)
22.CompareTo(22)
0
Integer (Int32)
10.CompareTo(22)
1
Integer (Int32)
intVar.CompareTo(10)
1
Integer (Int32)

Equals(Integer) - Determines if 2 Integers are equal

Example Method Example Return Return Type
22.Equals(10)
False
Boolean
22.Equals(22)
True
Boolean
intVar.Equals(22)
False
Boolean

ToString - Converts an Integer to a String

Example Method Example Return Return Type
22.ToString
"22"
String
-405.ToString
"-405"
String
intVar.ToString
"108"
String

Parse(String) - Converts a String to an Integer

Example Method Example Return Return Type
intVar.Parse("4835")
4835
Integer (Int32)
intVar.Parse("250")
250
Integer (Int32)

Parse(String,NumberStyles) - Converts a String to an Integer with NumberStyles

Example Method Example Return Return Type
intVar.Parse("3,835", System.Globalization. NumberStyles.AllowThousands)
3835
Integer (Int32)
intVar.Parse("-4005),System.Globalization. NumberStyles.AllowLeadingSign)
-4005
Integer (Int32)

GetType - Returns the data type

Example Method Example Return Return Type
Int16Variable.GetType
System.Int16
Type
Int32Variable.GetType
System.Int32
Type
Int64Variable.GetType
System.Int64
Type

What are NumberStyles?

When using the Parse method for Integer data types, you have the option of adding a NumberStyle as a parameter. NumberStyles allows you to specify any additional elements that are included in the string that will assist with converting it into an Integer. 

For Example, by using the AllowThousands NumberStyle, you can now parse strings that contain numbers and commas, not just a string with only numbers.

NumberStyles are written out as:

System.Globalization.NumberStyles.None

Let’s take a look at all the NumberStyles that can be used:

Value Allowed Elements Allowed Example
NumberStyles.None
None, digits only
3458
NumberStyles.AllowDecimalPoint
Decimal Point (.)
3458.79
NumberStyles.AllowExponent
Exponent Notation
3x10^1
NumberStyles.AllowLeadingWhite
Leading Whitespace ( )
3458
NumberStyles.AllowTrailingWhite
Trailing Whitespace ( )
3458
NumberStyles.AllowLeadingSign
Leading Sign (-)
-3458
NumberStyles.AllowTrailingSign
Trailing Sign (-)
3458-
NumberStyles.AllowParenthesis
Parenthesis (())
(3458)
NumberStyles.AllowThousands
Commas (,)
3,458
NumberStyles.AllowCurrenySymbol
Currency Symbol ($)
$3458
NumberStyles.Currency
All Styles, Except Exponent
($3,458.79)
NumberStyles.Float
WhiteSpace, Sign, Decimal, Exponent
3x10^1
NumberStyles.Number
Whitespace, Commas, Decimal
3,458.43
NumberStyles.Any
All Styles
($3,458.79)