uCalc API Version: 2.1.3-preview.2 Released: 6/16/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.

IsDefault = [bool]

Property

Product: 

Fast Math Parser

Class: 

DataType

Sets or unsets this data type as the engine's default for implicit typing.

Remarks

This property sets the data type for the current object as the default for its parent uCalc instance. It is a convenient shortcut for calling uCalc.DefaultDataType.

⚙️ How it Works

By default, uCalc uses Double as the data type for any variable or function parameter that is not explicitly typed. This method allows you to change that default.

  • Calling myIntType.IsDefault(true) is equivalent to calling uc.DefaultDataType(myIntType).
  • Calling myIntType.IsDefault(false) reverts the default data type back to Double if myIntType was the active default.

To check if a data type is the current default, use the getter overload: IsDefault().

🤔 Why Change the Default Data Type?

Changing the default is useful when an application's logic is primarily centered around a specific data type:

  • Integer-Based Applications: For applications dealing with counters, indices, or bitwise operations, setting the default to Int32 or Int64 avoids floating-point inaccuracies and can simplify code.
  • String Processing: For text manipulation tools, making String the default can be more intuitive.
  • Enforcing Precision: In financial or scientific applications, you might set Decimal or a custom high-precision numeric type as the default.

💡 Comparative Analysis

  • vs. C# var / C++ auto: In these languages, type is inferred from an initialization value (e.g., var x = 5; becomes an int). uCalc does this too, but if a variable is defined without an initial value (e.g., uc.DefineVariable("x")), it must fall back to a default type. This method controls that fallback.

  • vs. Visual Basic Option Strict Off: In VB, an untyped variable often defaults to Object. uCalc's approach is more specialized for mathematical and parsing contexts, defaulting to Double for performance and convenience in numerical calculations unless configured otherwise.

Examples

Sets a data type as the default
				
					using uCalcSoftware;

var uc = new uCalc();
Console.WriteLine(uc.DataTypeOf("double").IsDefault);
Console.WriteLine(uc.DataTypeOf("int64").IsDefault);
Console.WriteLine(uc.DefaultDataType.Name);
Console.WriteLine("---");

uc.DataTypeOf("int64").IsDefault = true;

Console.WriteLine(uc.DataTypeOf("double").IsDefault);
Console.WriteLine(uc.DataTypeOf("int64").IsDefault);
Console.WriteLine(uc.DefaultDataType.Name);
Console.WriteLine("---");

uc.DataTypeOf("int64").IsDefault = false;

Console.WriteLine(uc.DataTypeOf("double").IsDefault);
Console.WriteLine(uc.DataTypeOf("int64").IsDefault);
Console.WriteLine(uc.DefaultDataType.Name);
				
			
True
False
double
---
False
True
int64
---
True
False
double
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

#define tf(IsTrue) ((IsTrue) ? "True" : "False")

int main() {
   uCalc uc;
   cout << tf(uc.DataTypeOf("double").IsDefault()) << endl;
   cout << tf(uc.DataTypeOf("int64").IsDefault()) << endl;
   cout << uc.DefaultDataType().Name() << endl;
   cout << "---" << endl;

   uc.DataTypeOf("int64").IsDefault(true);

   cout << tf(uc.DataTypeOf("double").IsDefault()) << endl;
   cout << tf(uc.DataTypeOf("int64").IsDefault()) << endl;
   cout << uc.DefaultDataType().Name() << endl;
   cout << "---" << endl;

   uc.DataTypeOf("int64").IsDefault(false);

   cout << tf(uc.DataTypeOf("double").IsDefault()) << endl;
   cout << tf(uc.DataTypeOf("int64").IsDefault()) << endl;
   cout << uc.DefaultDataType().Name() << endl;
}
				
			
True
False
double
---
False
True
int64
---
True
False
double
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Console.WriteLine(uc.DataTypeOf("double").IsDefault)
      Console.WriteLine(uc.DataTypeOf("int64").IsDefault)
      Console.WriteLine(uc.DefaultDataType.Name)
      Console.WriteLine("---")
      
      uc.DataTypeOf("int64").IsDefault = true
      
      Console.WriteLine(uc.DataTypeOf("double").IsDefault)
      Console.WriteLine(uc.DataTypeOf("int64").IsDefault)
      Console.WriteLine(uc.DefaultDataType.Name)
      Console.WriteLine("---")
      
      uc.DataTypeOf("int64").IsDefault = false
      
      Console.WriteLine(uc.DataTypeOf("double").IsDefault)
      Console.WriteLine(uc.DataTypeOf("int64").IsDefault)
      Console.WriteLine(uc.DefaultDataType.Name)
   End Sub
End Module
				
			
True
False
double
---
False
True
int64
---
True
False
double
Succinct: Sets the default data type to `Int32` for implicit variable definitions.
				
					using uCalcSoftware;

var uc = new uCalc();
var intType = uc.DataTypeOf("Int32");
intType.IsDefault = true;

// Define a variable without specifying a type or initial value.
var myVar = uc.DefineVariable("myVar");

// Check the variable's type.
Console.WriteLine($"Default type is now: {uc.DefaultDataType.Name}");
Console.WriteLine($"myVar's type is: {myVar.DataType.Name}");
				
			
Default type is now: int
myVar's type is: int
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto intType = uc.DataTypeOf("Int32");
   intType.IsDefault(true);

   // Define a variable without specifying a type or initial value.
   auto myVar = uc.DefineVariable("myVar");

   // Check the variable's type.
   cout << "Default type is now: " << uc.DefaultDataType().Name() << endl;
   cout << "myVar's type is: " << myVar.DataType().Name() << endl;
}
				
			
Default type is now: int
myVar's type is: int
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim intType = uc.DataTypeOf("Int32")
      intType.IsDefault = true
      
      '// Define a variable without specifying a type or initial value.
      Dim myVar = uc.DefineVariable("myVar")
      
      '// Check the variable's type.
      Console.WriteLine($"Default type is now: {uc.DefaultDataType.Name}")
      Console.WriteLine($"myVar's type is: {myVar.DataType.Name}")
   End Sub
End Module
				
			
Default type is now: int
myVar's type is: int
Internal Test: Verifies the ability to set and unset a data type as the default.
				
					using uCalcSoftware;

var uc = new uCalc();
// Initial state: Double is the default
Console.WriteLine($"Double is default: {uc.DataTypeOf("double").IsDefault}");
Console.WriteLine($"Int64 is default: {uc.DataTypeOf("int64").IsDefault}");
Console.WriteLine($"Current default: {uc.DefaultDataType.Name}");
Console.WriteLine("---");

// Set Int64 as the default
uc.DataTypeOf("int64").IsDefault = true;
Console.WriteLine($"Double is default: {uc.DataTypeOf("double").IsDefault}");
Console.WriteLine($"Int64 is default: {uc.DataTypeOf("int64").IsDefault}");
Console.WriteLine($"Current default: {uc.DefaultDataType.Name}");
Console.WriteLine("---");

// Revert back to Double by un-setting Int64
uc.DataTypeOf("int64").IsDefault = false;
Console.WriteLine($"Double is default: {uc.DataTypeOf("double").IsDefault}");
Console.WriteLine($"Int64 is default: {uc.DataTypeOf("int64").IsDefault}");
Console.WriteLine($"Current default: {uc.DefaultDataType.Name}");
				
			
Double is default: True
Int64 is default: False
Current default: double
---
Double is default: False
Int64 is default: True
Current default: int64
---
Double is default: True
Int64 is default: False
Current default: double
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

#define tf(IsTrue) ((IsTrue) ? "True" : "False")

int main() {
   uCalc uc;
   // Initial state: Double is the default
   cout << "Double is default: " << tf(uc.DataTypeOf("double").IsDefault()) << endl;
   cout << "Int64 is default: " << tf(uc.DataTypeOf("int64").IsDefault()) << endl;
   cout << "Current default: " << uc.DefaultDataType().Name() << endl;
   cout << "---" << endl;

   // Set Int64 as the default
   uc.DataTypeOf("int64").IsDefault(true);
   cout << "Double is default: " << tf(uc.DataTypeOf("double").IsDefault()) << endl;
   cout << "Int64 is default: " << tf(uc.DataTypeOf("int64").IsDefault()) << endl;
   cout << "Current default: " << uc.DefaultDataType().Name() << endl;
   cout << "---" << endl;

   // Revert back to Double by un-setting Int64
   uc.DataTypeOf("int64").IsDefault(false);
   cout << "Double is default: " << tf(uc.DataTypeOf("double").IsDefault()) << endl;
   cout << "Int64 is default: " << tf(uc.DataTypeOf("int64").IsDefault()) << endl;
   cout << "Current default: " << uc.DefaultDataType().Name() << endl;
}
				
			
Double is default: True
Int64 is default: False
Current default: double
---
Double is default: False
Int64 is default: True
Current default: int64
---
Double is default: True
Int64 is default: False
Current default: double
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      '// Initial state: Double is the default
      Console.WriteLine($"Double is default: {uc.DataTypeOf("double").IsDefault}")
      Console.WriteLine($"Int64 is default: {uc.DataTypeOf("int64").IsDefault}")
      Console.WriteLine($"Current default: {uc.DefaultDataType.Name}")
      Console.WriteLine("---")
      
      '// Set Int64 as the default
      uc.DataTypeOf("int64").IsDefault = true
      Console.WriteLine($"Double is default: {uc.DataTypeOf("double").IsDefault}")
      Console.WriteLine($"Int64 is default: {uc.DataTypeOf("int64").IsDefault}")
      Console.WriteLine($"Current default: {uc.DefaultDataType.Name}")
      Console.WriteLine("---")
      
      '// Revert back to Double by un-setting Int64
      uc.DataTypeOf("int64").IsDefault = false
      Console.WriteLine($"Double is default: {uc.DataTypeOf("double").IsDefault}")
      Console.WriteLine($"Int64 is default: {uc.DataTypeOf("int64").IsDefault}")
      Console.WriteLine($"Current default: {uc.DefaultDataType.Name}")
   End Sub
End Module
				
			
Double is default: True
Int64 is default: False
Current default: double
---
Double is default: False
Int64 is default: True
Current default: int64
---
Double is default: True
Int64 is default: False
Current default: double