Data TypesLast Updated: 07/29/2016 Introduced in Verision: 2.0 |
This document overviews commonly used Data Types in Decisions and explains what Data Types should be used for what purposes.
Every variable in Decisions or a process that evaluates to a value has its Type. It could be a simple Type (Int32, Boolean, String) or a complex Type (Account, Database Structure). Every Step in the Flow Designer specifies a type for each input parameter and for the return value. Decisions defines a set of built-in numeric types as well as more complex types that represent a wide variety of logical constructs, such as the file system, network connections, collections and arrays of objects, and dates. Typical Workflow uses Decisions Native Types as well as User-Defined Types that model the concepts that are specific to the Flow’s problem domain. This is why it is important which Data Type to use in which case.
The information stored in a Type can include the following:
- The storage space that a variable of the type requires.
- The maximum and minimum values that it can represent.
- The members (methods, fields, events, and so on) that it contains.
- The base type it inherits from.
- The location where the memory for variables will be allocated at run time.
- The kinds of operations that are permitted.
In the following figure we are trying to perform mathematical addition with two variables: Int32 and String. The value of String is ‘6’ but it could be changed to any text, therefore we are getting Validation issue in the Mapping Editor.
Next, we are going to overview the most used Data Types in Decisions.
In the case where we need to perform some calculations with Data we want to use Integral and Floating Point Types.
Integral Types:
Type |
Range |
Size |
SByte |
-128 to 127 |
Signed 8-bit integer |
Byte |
0 to 255 |
Unsigned 8-bit integer |
Char |
U+0000 to U+ffff |
Unicode 16-bit character |
Int16 |
-32,768 to 32,767 |
Signed 16-bit integer |
Int32 |
-2,147,483,648 to 2,147,483,647 |
Signed 32-bit integer |
Int64 |
-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
Signed 64-bit integer |
UInt64 |
0 to 18,446,744,073,709,551,615 |
Unsigned 64-bit integer |
Int32 Type is the most commonly used in Decisions for arithmetical calculations.
Floating Point Types
Type |
Approximate Range |
Precision |
Single |
±1.5e−45 to ±3.4e38 |
7 digits |
Double |
±5.0e−324 to ±1.7e308 |
15-16 digits |
Decimal |
(-7.9 x 1028 to 7.9 x 1028) / (100 to 28) |
28-29 digits |
Single and Double are floating binary point types. In other words, they represent a number like this:
10001.10010110011
The binary number and the location of the binary point are both encoded within the value.
Decimal is a floating decimal point type. In other words, they represent a number like this:
12345.65789
Again, the number and the location of the decimal point are both encoded within the value – that’s what makes decimal still a floating point type instead of a fixed point type.
For values which are “naturally exact decimals” it’s good to use decimal. This is usually suitable for any concepts invented by humans: financial values are the most obvious example, but there are others too. Consider the score given to divers or ice skaters, for example.
For values which are more artefacts of nature which can’t really be measured exactly anyway, float/double are more appropriate. For example, scientific data would usually be represented in this form. Here, the original values won’t be “decimally accurate” to start with, so it’s not important for the expected results to maintain the “decimal accuracy”. Floating binary point types are much faster to work with than decimals.
String – represents text as a series of Unicode characters. String Type is used for all text data manipulations.
TimeSpan – represents a time interval. The structure of this type is following…
DateTime – represents an instant in time, typically expressed as a date and time of day.
Boolean – represents a Boolean (true or false) value. Used in logical evaluations like ‘Yes’ or ‘No’.
FileData – represents File in Decisions. Contains following members: Content (Byte Array), FileName (String), FileType (String), Length (Int32), Tag (Object).