uCalc API Version: 5.7.0-preview.1 Released: 7/30/2026

Warning

uCalc API Preview Release Notice:This preview documentation describes the intended behavior of the API. It is not fully accurate or complete.The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.Use of the preview version in your production code is not recommended.

DataTypeOf(BuiltInType)

Method

Product: 

Class: 

Retrieves the DataType object associated with a specific built-in type enumeration.

Syntax

DataTypeOf(BuiltInType)

Parameters

typeEnum
BuiltInType
The built-in type enumeration member (e.g., BuiltInType::Int32).

Return

DataType

The DataType object corresponding to the specified enum.

Remarks

The DataTypeOf method retrieves the DataType object corresponding to a member of the BuiltInType enumeration.

Instance-Specific Data Types

Every uCalc instance manages its own registry of data type objects. For example, uc1.DataTypeOf(BuiltInType::Integer_32) and uc2.DataTypeOf(BuiltInType::Integer_32) return two different objects. This architecture allows you to customize properties (such as display formatting or names) for a type in one parser instance without affecting others.

Usage

Use this method when you need to:

  • Inspect properties of a standard type (e.g., ByteSize, Name).
  • Set the default data type for the engine via DefaultDataType.
  • Perform type comparisons (checking if a generic Item matches a specific built-in type).

If you need to retrieve a data type by its string name (e.g., "Integer"), use the string overload of this method or ItemOf.

Examples

Getting data type object with DataTypeOf

ID: 2

				
					using uCalcSoftware;

var uc = new uCalc();
Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_8u).ToString("-1"));
Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_16u).ToString("-1"));
Console.WriteLine(uc.DataTypeOf(BuiltInType.Boolean).ToString("-1"));
Console.WriteLine(uc.DataTypeOf(BuiltInType.String).ToString("-1"));

Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_8u).Name);
Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_32).ByteSize);
				
			
255
65535
true
-1
int8u
4
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   cout << uc.DataTypeOf(BuiltInType::Integer_8u).ToString("-1") << endl;
   cout << uc.DataTypeOf(BuiltInType::Integer_16u).ToString("-1") << endl;
   cout << uc.DataTypeOf(BuiltInType::Boolean).ToString("-1") << endl;
   cout << uc.DataTypeOf(BuiltInType::String).ToString("-1") << endl;

   cout << uc.DataTypeOf(BuiltInType::Integer_8u).Name() << endl;
   cout << uc.DataTypeOf(BuiltInType::Integer_32).ByteSize() << endl;
}
				
			
255
65535
true
-1
int8u
4
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_8u).ToString("-1"))
      Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_16u).ToString("-1"))
      Console.WriteLine(uc.DataTypeOf(BuiltInType.Boolean).ToString("-1"))
      Console.WriteLine(uc.DataTypeOf(BuiltInType.String).ToString("-1"))
      
      Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_8u).Name)
      Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_32).ByteSize)
   End Sub
End Module
				
			
255
65535
true
-1
int8u
4
Introspection and conversion using standard types

ID: 277

				
					using uCalcSoftware;

var uc = new uCalc();
// Inspect basic properties of built-in types
Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_8u).Name);
Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_32).ByteSize);

// Testing edge case conversions mentioned in development notes
// Also string conversion behavior for signed vs unsigned and complex types
Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_8u).ToString("-1"));
Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_16u).ToString("-1"));
Console.WriteLine(uc.DataTypeOf(BuiltInType.String).ToString("-1"));
Console.WriteLine(uc.DataTypeOf(BuiltInType.Boolean).ToString("-1"));
				
			
int8u
4
255
65535
-1
true
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   // Inspect basic properties of built-in types
   cout << uc.DataTypeOf(BuiltInType::Integer_8u).Name() << endl;
   cout << uc.DataTypeOf(BuiltInType::Integer_32).ByteSize() << endl;

   // Testing edge case conversions mentioned in development notes
   // Also string conversion behavior for signed vs unsigned and complex types
   cout << uc.DataTypeOf(BuiltInType::Integer_8u).ToString("-1") << endl;
   cout << uc.DataTypeOf(BuiltInType::Integer_16u).ToString("-1") << endl;
   cout << uc.DataTypeOf(BuiltInType::String).ToString("-1") << endl;
   cout << uc.DataTypeOf(BuiltInType::Boolean).ToString("-1") << endl;
}
				
			
int8u
4
255
65535
-1
true
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      '// Inspect basic properties of built-in types
      Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_8u).Name)
      Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_32).ByteSize)
      
      '// Testing edge case conversions mentioned in development notes
      '// Also string conversion behavior for signed vs unsigned and complex types
      Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_8u).ToString("-1"))
      Console.WriteLine(uc.DataTypeOf(BuiltInType.Integer_16u).ToString("-1"))
      Console.WriteLine(uc.DataTypeOf(BuiltInType.String).ToString("-1"))
      Console.WriteLine(uc.DataTypeOf(BuiltInType.Boolean).ToString("-1"))
   End Sub
End Module
				
			
int8u
4
255
65535
-1
true
Checking variable types against BuiltInType

ID: 278

				
					using uCalcSoftware;

var uc = new uCalc();
// Define a variable with a specific type
uc.DefineVariable("myVar As Int16");

// Retrieve the generic Int16 type object
var typeObj = uc.DataTypeOf(BuiltInType.Integer_16);

// Check if the variable's type matches Int16
if (uc.ItemOf("myVar").DataType.BuiltInTypeEnum == typeObj.BuiltInTypeEnum) {
   Console.WriteLine("Variable 'myVar' is an Int16.");
} else {
   Console.WriteLine("Type mismatch.");
}
				
			
Variable 'myVar' is an Int16.
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   // Define a variable with a specific type
   uc.DefineVariable("myVar As Int16");

   // Retrieve the generic Int16 type object
   auto typeObj = uc.DataTypeOf(BuiltInType::Integer_16);

   // Check if the variable's type matches Int16
   if (uc.ItemOf("myVar").DataType().BuiltInTypeEnum() == typeObj.BuiltInTypeEnum()) {
      cout << "Variable 'myVar' is an Int16." << endl;
   } else {
      cout << "Type mismatch." << endl;
   }
}
				
			
Variable 'myVar' is an Int16.
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      '// Define a variable with a specific type
      uc.DefineVariable("myVar As Int16")
      
      '// Retrieve the generic Int16 type object
      Dim typeObj = uc.DataTypeOf(BuiltInType.Integer_16)
      
      '// Check if the variable's type matches Int16
      If uc.ItemOf("myVar").DataType.BuiltInTypeEnum = typeObj.BuiltInTypeEnum Then
         Console.WriteLine("Variable 'myVar' is an Int16.")
      Else
         Console.WriteLine("Type mismatch.")
      End If
   End Sub
End Module
				
			
Variable 'myVar' is an Int16.