uCalc API Version: 2.1.3-preview.2 Released: 6/17/2026
Warning
uCalc API Preview Release Notice:The documentation describes the intended behavior of the API. The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.
BuiltInTypeEnum = [BuiltInType]
Property
Product:
Class:
Retrieves the BuiltInType enumeration member that uniquely identifies a built-in data type.
Remarks
This method returns the specific BuiltInType enum member that corresponds to the DataType object. It provides a fast and reliable way to identify built-in types using a stable, numeric code.
🎯 Why Use This Method?
While you can identify a type by its Name (e.g., "Double"), using its enum value is often superior for several reasons:
- Performance: Comparing two integers is significantly faster than comparing two strings. This is critical in performance-sensitive callbacks or tight loops.
- Robustness: The enum value is stable. The display name of a data type might be changed or localized, but its underlying
BuiltInTypemember will remain the same. - Clarity in Logic: The enum is ideal for use in
switchstatements orif/else ifchains, making type-dispatching logic clean and readable.
⚖️ Comparative Analysis
vs. .NET
Type.GetTypeCode(): This method is functionally very similar toGetTypeCode()in the .NET Framework, which returns aTypeCodeenum for primitive types. Developers familiar with this pattern will find this method intuitive.vs. C++
typeidandstd::is_same: In C++, type identification is often done at compile-time with templates or at runtime with RTTI (typeid). uCalc's method provides a simple, runtime mechanism that works consistently across all supported languages (C#, C++, VB) without requiring complex template metaprogramming.
The Name() method is good for display and logging, while this method is designed for programmatic logic and type checking.
Examples
Operator ByRef, AnyType, SameTypeAs, Precedence, RightToLeft, callback
using uCalcSoftware;
var uc = new uCalc();
static void AssignValueA(uCalc.Callback cb) {
cb.uCalc.DataTypeOf(BuiltInType.Integer_64).SetScalar(cb.ArgPtr(1), cb.ArgAddr(2));
// C++ can do it with pointers instead like the commented line below:
// *(int64_t *)cb.ArgInt64(1) = cb.ArgInt64(2);
}
static void AssignValueB(uCalc.Callback cb) {
if (cb.ArgItem(1).DataType.BuiltInTypeEnum == BuiltInType.String) {
cb.ArgItem(1).ValueStr(cb.ArgItem(2).ValueStr());
} else {
cb.ArgItem(1).DataType.SetScalar(cb.ArgItem(1).ValueAddr(), cb.ArgItem(2).ValueAddr());
}
}
// ByRef approach (only for primitive types only, like double, int, etc., not composite types like strings)
Console.WriteLine("-- ByRef approach --");
uc.DefineOperator("{ByRef variable As AnyType} SetValA {value As SameTypeAs:0} As SameTypeAs:0", uc.ItemOf("=").Precedence, Associativity.RightToLeft, AssignValueA);
uc.DefineVariable("MyDbl As Double");
uc.DefineVariable("MyInt As Int");
uc.DefineVariable("MyStr As String");
uc.Eval("MyDbl SetValA 3.14");
uc.Eval("MyInt SetValA Int(3.14 * 10)");
Console.WriteLine("MyDbl: " + uc.EvalStr("MyDbl"));
Console.WriteLine("MyInt: " + uc.EvalStr("MyInt"));
// ByHandle approach
Console.WriteLine("-- ByHandle approach --");
uc.DefineOperator("{ByHandle variable As AnyType} SetValB {ByHandle val As SameTypeAs:0}", uc.ItemOf("=").Precedence, Associativity.RightToLeft, AssignValueB);
uc.Eval("MyDbl SetValB 123.456");
uc.Eval("MyInt SetValB Int(555.123)");
uc.Eval("MyStr SetValB 'Hello World'");
Console.WriteLine("MyDbl: " + uc.EvalStr("MyDbl"));
Console.WriteLine("MyInt: " + uc.EvalStr("MyInt"));
Console.WriteLine("MyStr: " + uc.EvalStr("MyStr"));
-- ByRef approach --
MyDbl: 3.14
MyInt: 31
-- ByHandle approach --
MyDbl: 123.456
MyInt: 555
MyStr: Hello World using uCalcSoftware; var uc = new uCalc(); static void AssignValueA(uCalc.Callback cb) { cb.uCalc.DataTypeOf(BuiltInType.Integer_64).SetScalar(cb.ArgPtr(1), cb.ArgAddr(2)); // C++ can do it with pointers instead like the commented line below: // *(int64_t *)cb.ArgInt64(1) = cb.ArgInt64(2); } static void AssignValueB(uCalc.Callback cb) { if (cb.ArgItem(1).DataType.BuiltInTypeEnum == BuiltInType.String) { cb.ArgItem(1).ValueStr(cb.ArgItem(2).ValueStr()); } else { cb.ArgItem(1).DataType.SetScalar(cb.ArgItem(1).ValueAddr(), cb.ArgItem(2).ValueAddr()); } } // ByRef approach (only for primitive types only, like double, int, etc., not composite types like strings) Console.WriteLine("-- ByRef approach --"); uc.DefineOperator("{ByRef variable As AnyType} SetValA {value As SameTypeAs:0} As SameTypeAs:0", uc.ItemOf("=").Precedence, Associativity.RightToLeft, AssignValueA); uc.DefineVariable("MyDbl As Double"); uc.DefineVariable("MyInt As Int"); uc.DefineVariable("MyStr As String"); uc.Eval("MyDbl SetValA 3.14"); uc.Eval("MyInt SetValA Int(3.14 * 10)"); Console.WriteLine("MyDbl: " + uc.EvalStr("MyDbl")); Console.WriteLine("MyInt: " + uc.EvalStr("MyInt")); // ByHandle approach Console.WriteLine("-- ByHandle approach --"); uc.DefineOperator("{ByHandle variable As AnyType} SetValB {ByHandle val As SameTypeAs:0}", uc.ItemOf("=").Precedence, Associativity.RightToLeft, AssignValueB); uc.Eval("MyDbl SetValB 123.456"); uc.Eval("MyInt SetValB Int(555.123)"); uc.Eval("MyStr SetValB 'Hello World'"); Console.WriteLine("MyDbl: " + uc.EvalStr("MyDbl")); Console.WriteLine("MyInt: " + uc.EvalStr("MyInt")); Console.WriteLine("MyStr: " + uc.EvalStr("MyStr"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
void ucalc_call AssignValueA(uCalcBase::Callback cb) {
cb.uCalc().DataTypeOf(BuiltInType::Integer_64).SetScalar(cb.ArgPtr(1), cb.ArgAddr(2));
// C++ can do it with pointers instead like the commented line below:
// *(int64_t *)cb.ArgInt64(1) = cb.ArgInt64(2);
}
void ucalc_call AssignValueB(uCalcBase::Callback cb) {
if (cb.ArgItem(1).DataType().BuiltInTypeEnum() == BuiltInType::String) {
cb.ArgItem(1).ValueStr(cb.ArgItem(2).ValueStr());
} else {
cb.ArgItem(1).DataType().SetScalar(cb.ArgItem(1).ValueAddr(), cb.ArgItem(2).ValueAddr());
}
}
int main() {
uCalc uc;
// ByRef approach (only for primitive types only, like double, int, etc., not composite types like strings)
cout << "-- ByRef approach --" << endl;
uc.DefineOperator("{ByRef variable As AnyType} SetValA {value As SameTypeAs:0} As SameTypeAs:0", uc.ItemOf("=").Precedence(), Associativity::RightToLeft, AssignValueA);
uc.DefineVariable("MyDbl As Double");
uc.DefineVariable("MyInt As Int");
uc.DefineVariable("MyStr As String");
uc.Eval("MyDbl SetValA 3.14");
uc.Eval("MyInt SetValA Int(3.14 * 10)");
cout << "MyDbl: " + uc.EvalStr("MyDbl") << endl;
cout << "MyInt: " + uc.EvalStr("MyInt") << endl;
// ByHandle approach
cout << "-- ByHandle approach --" << endl;
uc.DefineOperator("{ByHandle variable As AnyType} SetValB {ByHandle val As SameTypeAs:0}", uc.ItemOf("=").Precedence(), Associativity::RightToLeft, AssignValueB);
uc.Eval("MyDbl SetValB 123.456");
uc.Eval("MyInt SetValB Int(555.123)");
uc.Eval("MyStr SetValB 'Hello World'");
cout << "MyDbl: " + uc.EvalStr("MyDbl") << endl;
cout << "MyInt: " + uc.EvalStr("MyInt") << endl;
cout << "MyStr: " + uc.EvalStr("MyStr") << endl;
}
-- ByRef approach --
MyDbl: 3.14
MyInt: 31
-- ByHandle approach --
MyDbl: 123.456
MyInt: 555
MyStr: Hello World #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; void ucalc_call AssignValueA(uCalcBase::Callback cb) { cb.uCalc().DataTypeOf(BuiltInType::Integer_64).SetScalar(cb.ArgPtr(1), cb.ArgAddr(2)); // C++ can do it with pointers instead like the commented line below: // *(int64_t *)cb.ArgInt64(1) = cb.ArgInt64(2); } void ucalc_call AssignValueB(uCalcBase::Callback cb) { if (cb.ArgItem(1).DataType().BuiltInTypeEnum() == BuiltInType::String) { cb.ArgItem(1).ValueStr(cb.ArgItem(2).ValueStr()); } else { cb.ArgItem(1).DataType().SetScalar(cb.ArgItem(1).ValueAddr(), cb.ArgItem(2).ValueAddr()); } } int main() { uCalc uc; // ByRef approach (only for primitive types only, like double, int, etc., not composite types like strings) cout << "-- ByRef approach --" << endl; uc.DefineOperator("{ByRef variable As AnyType} SetValA {value As SameTypeAs:0} As SameTypeAs:0", uc.ItemOf("=").Precedence(), Associativity::RightToLeft, AssignValueA); uc.DefineVariable("MyDbl As Double"); uc.DefineVariable("MyInt As Int"); uc.DefineVariable("MyStr As String"); uc.Eval("MyDbl SetValA 3.14"); uc.Eval("MyInt SetValA Int(3.14 * 10)"); cout << "MyDbl: " + uc.EvalStr("MyDbl") << endl; cout << "MyInt: " + uc.EvalStr("MyInt") << endl; // ByHandle approach cout << "-- ByHandle approach --" << endl; uc.DefineOperator("{ByHandle variable As AnyType} SetValB {ByHandle val As SameTypeAs:0}", uc.ItemOf("=").Precedence(), Associativity::RightToLeft, AssignValueB); uc.Eval("MyDbl SetValB 123.456"); uc.Eval("MyInt SetValB Int(555.123)"); uc.Eval("MyStr SetValB 'Hello World'"); cout << "MyDbl: " + uc.EvalStr("MyDbl") << endl; cout << "MyInt: " + uc.EvalStr("MyInt") << endl; cout << "MyStr: " + uc.EvalStr("MyStr") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub AssignValueA(ByVal cb As uCalc.Callback)
cb.uCalc.DataTypeOf(BuiltInType.Integer_64).SetScalar(cb.ArgPtr(1), cb.ArgAddr(2))
'// C++ can do it with pointers instead like the commented line below:
'// *(int64_t *)cb.ArgInt64(1) = cb.ArgInt64(2);
End Sub
Public Sub AssignValueB(ByVal cb As uCalc.Callback)
If cb.ArgItem(1).DataType.BuiltInTypeEnum = BuiltInType.String Then
cb.ArgItem(1).ValueStr(cb.ArgItem(2).ValueStr())
Else
cb.ArgItem(1).DataType.SetScalar(cb.ArgItem(1).ValueAddr(), cb.ArgItem(2).ValueAddr())
End If
End Sub
Public Sub Main()
Dim uc As New uCalc()
'// ByRef approach (only for primitive types only, like double, int, etc., not composite types like strings)
Console.WriteLine("-- ByRef approach --")
uc.DefineOperator("{ByRef variable As AnyType} SetValA {value As SameTypeAs:0} As SameTypeAs:0", uc.ItemOf("=").Precedence, Associativity.RightToLeft, AddressOf AssignValueA)
uc.DefineVariable("MyDbl As Double")
uc.DefineVariable("MyInt As Int")
uc.DefineVariable("MyStr As String")
uc.Eval("MyDbl SetValA 3.14")
uc.Eval("MyInt SetValA Int(3.14 * 10)")
Console.WriteLine("MyDbl: " + uc.EvalStr("MyDbl"))
Console.WriteLine("MyInt: " + uc.EvalStr("MyInt"))
'// ByHandle approach
Console.WriteLine("-- ByHandle approach --")
uc.DefineOperator("{ByHandle variable As AnyType} SetValB {ByHandle val As SameTypeAs:0}", uc.ItemOf("=").Precedence, Associativity.RightToLeft, AddressOf AssignValueB)
uc.Eval("MyDbl SetValB 123.456")
uc.Eval("MyInt SetValB Int(555.123)")
uc.Eval("MyStr SetValB 'Hello World'")
Console.WriteLine("MyDbl: " + uc.EvalStr("MyDbl"))
Console.WriteLine("MyInt: " + uc.EvalStr("MyInt"))
Console.WriteLine("MyStr: " + uc.EvalStr("MyStr"))
End Sub
End Module
-- ByRef approach --
MyDbl: 3.14
MyInt: 31
-- ByHandle approach --
MyDbl: 123.456
MyInt: 555
MyStr: Hello World Imports System Imports uCalcSoftware Public Module Program Public Sub AssignValueA(ByVal cb As uCalc.Callback) cb.uCalc.DataTypeOf(BuiltInType.Integer_64).SetScalar(cb.ArgPtr(1), cb.ArgAddr(2)) '// C++ can do it with pointers instead like the commented line below: '// *(int64_t *)cb.ArgInt64(1) = cb.ArgInt64(2); End Sub Public Sub AssignValueB(ByVal cb As uCalc.Callback) If cb.ArgItem(1).DataType.BuiltInTypeEnum = BuiltInType.String Then cb.ArgItem(1).ValueStr(cb.ArgItem(2).ValueStr()) Else cb.ArgItem(1).DataType.SetScalar(cb.ArgItem(1).ValueAddr(), cb.ArgItem(2).ValueAddr()) End If End Sub Public Sub Main() Dim uc As New uCalc() '// ByRef approach (only for primitive types only, like double, int, etc., not composite types like strings) Console.WriteLine("-- ByRef approach --") uc.DefineOperator("{ByRef variable As AnyType} SetValA {value As SameTypeAs:0} As SameTypeAs:0", uc.ItemOf("=").Precedence, Associativity.RightToLeft, AddressOf AssignValueA) uc.DefineVariable("MyDbl As Double") uc.DefineVariable("MyInt As Int") uc.DefineVariable("MyStr As String") uc.Eval("MyDbl SetValA 3.14") uc.Eval("MyInt SetValA Int(3.14 * 10)") Console.WriteLine("MyDbl: " + uc.EvalStr("MyDbl")) Console.WriteLine("MyInt: " + uc.EvalStr("MyInt")) '// ByHandle approach Console.WriteLine("-- ByHandle approach --") uc.DefineOperator("{ByHandle variable As AnyType} SetValB {ByHandle val As SameTypeAs:0}", uc.ItemOf("=").Precedence, Associativity.RightToLeft, AddressOf AssignValueB) uc.Eval("MyDbl SetValB 123.456") uc.Eval("MyInt SetValB Int(555.123)") uc.Eval("MyStr SetValB 'Hello World'") Console.WriteLine("MyDbl: " + uc.EvalStr("MyDbl")) Console.WriteLine("MyInt: " + uc.EvalStr("MyInt")) Console.WriteLine("MyStr: " + uc.EvalStr("MyStr")) End Sub End Module