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.

FormatRemove

Method

Product: 

Fast Math Parser

Class: 

uCalcBase

Removes one or all custom output formatting rules previously defined with the Format method.

Syntax

FormatRemove(DataType)

Parameters

targetType
DataType
(Default = Empty)
Optional. The data type whose formatting rules should be removed. If omitted, all formatting rules for all types are removed.

Return

void

This method does not return a value.

Remarks

FormatRemove clears one or more custom output formatting rules that were previously defined using uCalc.Format. This restores the default string representation for evaluated results.

You can use this method in two ways:

  • Remove All Formatting: Call FormatRemove() with no arguments to clear every formatting rule for all data types within the current uCalc instance.
  • Remove Type-Specific Formatting: Pass a DataType object (e.g., uc.DataTypeOf("String")) to remove only the formatting rules associated with that specific type, leaving others intact.

This is useful for dynamically changing the output style of your application or for cleaning up temporary formatting rules.

Temporary Suppression vs. Permanent Removal

It's important to distinguish between removing a format and temporarily suppressing it.

  • uc.FormatRemove(): Permanently deletes the formatting rule(s). They must be redefined with uCalc.Format to be used again.
  • uc.EvalStr(expression, false): Temporarily bypasses all formatting for a single evaluation. The rules remain defined and will apply to subsequent EvalStr calls that don't explicitly disable them.

🏛️ Comparative Analysis

Most programming languages handle formatting at the point of conversion to a string, often using format specifiers.

  • C-style printf / sprintf: printf("Value: %.2f", my_var);
  • C# String Formatting: myVar.ToString("F2"); or $"Value: {myVar:F2}"
  • Python f-strings: f"Value: {my_var:.2f}"

These approaches are imperative and localized; the formatting logic is applied wherever the string is generated.

uCalc's uCalc.Format and FormatRemove system is declarative and centralized. You define formatting rules once per uCalc instance, and they are automatically applied to all relevant EvalStr or EvaluateStr results. This is more akin to middleware or Aspect-Oriented Programming (AOP), where cross-cutting concerns (like output formatting) are managed separately from the core evaluation logic. FormatRemove provides the dynamic ability to tear down this "middleware" at runtime, offering a level of control not typically found in standard library formatters.

Examples

Different output formats for different data types
				
					using uCalcSoftware;

var uc = new uCalc();
// String results will be surrounded by << and >>, while Boolean will be surrounded by [[ and ]]
uc.Format("DataType: String, Def: val = '<<' + val + '>>' ");
uc.Format("Bool, val = '[[' + val + ']]'"); // Shortcut notation without "DataType" or "Def"

Console.WriteLine(uc.EvalStr("10+20"));
Console.WriteLine(uc.EvalStr("'Hello '+'world'"));
Console.WriteLine(uc.EvalStr("5 > 10"));
Console.WriteLine(uc.EvalStr("5 < 10"));

uc.FormatRemove();
Console.WriteLine("---");
Console.WriteLine(uc.EvalStr("10+20"));
Console.WriteLine(uc.EvalStr("'Hello '+'world'"));
Console.WriteLine(uc.EvalStr("5 > 10"));
Console.WriteLine(uc.EvalStr("5 < 10"));
				
			
30
<<Hello world>>
[[false]]
[[true]]
---
30
Hello world
false
true
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   // String results will be surrounded by << and >>, while Boolean will be surrounded by [[ and ]]
   uc.Format("DataType: String, Def: val = '<<' + val + '>>' ");
   uc.Format("Bool, val = '[[' + val + ']]'"); // Shortcut notation without "DataType" or "Def"

   cout << uc.EvalStr("10+20") << endl;
   cout << uc.EvalStr("'Hello '+'world'") << endl;
   cout << uc.EvalStr("5 > 10") << endl;
   cout << uc.EvalStr("5 < 10") << endl;

   uc.FormatRemove();
   cout << "---" << endl;
   cout << uc.EvalStr("10+20") << endl;
   cout << uc.EvalStr("'Hello '+'world'") << endl;
   cout << uc.EvalStr("5 > 10") << endl;
   cout << uc.EvalStr("5 < 10") << endl;
}
				
			
30
<<Hello world>>
[[false]]
[[true]]
---
30
Hello world
false
true
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      '// String results will be surrounded by << and >>, while Boolean will be surrounded by [[ and ]]
      uc.Format("DataType: String, Def: val = '<<' + val + '>>' ")
      uc.Format("Bool, val = '[[' + val + ']]'") '// Shortcut notation without "DataType" or "Def"
      
      Console.WriteLine(uc.EvalStr("10+20"))
      Console.WriteLine(uc.EvalStr("'Hello '+'world'"))
      Console.WriteLine(uc.EvalStr("5 > 10"))
      Console.WriteLine(uc.EvalStr("5 < 10"))
      
      uc.FormatRemove()
      Console.WriteLine("---")
      Console.WriteLine(uc.EvalStr("10+20"))
      Console.WriteLine(uc.EvalStr("'Hello '+'world'"))
      Console.WriteLine(uc.EvalStr("5 > 10"))
      Console.WriteLine(uc.EvalStr("5 < 10"))
   End Sub
End Module
				
			
30
<<Hello world>>
[[false]]
[[true]]
---
30
Hello world
false
true
Inserts formatting in specified sequence
				
					using uCalcSoftware;

var uc = new uCalc();
uc.Format("Result = 'Answer: ' + Result");
uc.Format("DataType: String, Def: val = '<<' + val + '>>' ");
uc.Format("DataType: Bool, Def: val = '[[' + val + ']]'");

// Note the difference between where "Bool: " and "String: " are displayed in the result
uc.Format("InsertAt: 0, DataType: Bool, Def: val = 'Bool: ' + val");  // Inserts at 0th position of Bool
uc.Format("InsertAt: 1, DataType: String, Def: val = 'String: ' + val"); // Inserts at 1st position of String
Console.WriteLine(uc.EvalStr("10+20"));
Console.WriteLine(uc.EvalStr("'Hello '+'world'"));
Console.WriteLine(uc.EvalStr("5 > 10"));
Console.WriteLine("---");

// This fomratting will be the last one to take effect
uc.Format("InsertAt: 0, Def: val = 'Outer: ' + val");
Console.WriteLine(uc.EvalStr("10+20"));
Console.WriteLine(uc.EvalStr("'Hello '+'world'"));
Console.WriteLine(uc.EvalStr("5 > 10"));
Console.WriteLine("---");

// This formatting will be the first one to take effect
uc.Format("val = 'Inner: ' + val"); // Optionally InsertAt: -1 could have been used
Console.WriteLine(uc.EvalStr("10+20"));
Console.WriteLine(uc.EvalStr("'Hello '+'world'"));
Console.WriteLine(uc.EvalStr("5 > 10"));
Console.WriteLine("---");

uc.FormatRemove();

Console.WriteLine(uc.EvalStr("10+20"));
Console.WriteLine(uc.EvalStr("'Hello '+'world'"));
Console.WriteLine(uc.EvalStr("5 > 10"));
				
			
Answer: 30
Answer: String: <<Hello world>>
Bool: Answer: [[false]]
---
Outer: Answer: 30
Outer: Answer: String: <<Hello world>>
Outer: Bool: Answer: [[false]]
---
Outer: Answer: Inner: 30
Outer: Answer: String: <<Inner: Hello world>>
Outer: Bool: Answer: [[Inner: false]]
---
30
Hello world
false
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uc.Format("Result = 'Answer: ' + Result");
   uc.Format("DataType: String, Def: val = '<<' + val + '>>' ");
   uc.Format("DataType: Bool, Def: val = '[[' + val + ']]'");

   // Note the difference between where "Bool: " and "String: " are displayed in the result
   uc.Format("InsertAt: 0, DataType: Bool, Def: val = 'Bool: ' + val");  // Inserts at 0th position of Bool
   uc.Format("InsertAt: 1, DataType: String, Def: val = 'String: ' + val"); // Inserts at 1st position of String
   cout << uc.EvalStr("10+20") << endl;
   cout << uc.EvalStr("'Hello '+'world'") << endl;
   cout << uc.EvalStr("5 > 10") << endl;
   cout << "---" << endl;

   // This fomratting will be the last one to take effect
   uc.Format("InsertAt: 0, Def: val = 'Outer: ' + val");
   cout << uc.EvalStr("10+20") << endl;
   cout << uc.EvalStr("'Hello '+'world'") << endl;
   cout << uc.EvalStr("5 > 10") << endl;
   cout << "---" << endl;

   // This formatting will be the first one to take effect
   uc.Format("val = 'Inner: ' + val"); // Optionally InsertAt: -1 could have been used
   cout << uc.EvalStr("10+20") << endl;
   cout << uc.EvalStr("'Hello '+'world'") << endl;
   cout << uc.EvalStr("5 > 10") << endl;
   cout << "---" << endl;

   uc.FormatRemove();

   cout << uc.EvalStr("10+20") << endl;
   cout << uc.EvalStr("'Hello '+'world'") << endl;
   cout << uc.EvalStr("5 > 10") << endl;
}
				
			
Answer: 30
Answer: String: <<Hello world>>
Bool: Answer: [[false]]
---
Outer: Answer: 30
Outer: Answer: String: <<Hello world>>
Outer: Bool: Answer: [[false]]
---
Outer: Answer: Inner: 30
Outer: Answer: String: <<Inner: Hello world>>
Outer: Bool: Answer: [[Inner: false]]
---
30
Hello world
false
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      uc.Format("Result = 'Answer: ' + Result")
      uc.Format("DataType: String, Def: val = '<<' + val + '>>' ")
      uc.Format("DataType: Bool, Def: val = '[[' + val + ']]'")
      
      '// Note the difference between where "Bool: " and "String: " are displayed in the result
      uc.Format("InsertAt: 0, DataType: Bool, Def: val = 'Bool: ' + val")  '// Inserts at 0th position of Bool
      uc.Format("InsertAt: 1, DataType: String, Def: val = 'String: ' + val") '// Inserts at 1st position of String
      Console.WriteLine(uc.EvalStr("10+20"))
      Console.WriteLine(uc.EvalStr("'Hello '+'world'"))
      Console.WriteLine(uc.EvalStr("5 > 10"))
      Console.WriteLine("---")
      
      '// This fomratting will be the last one to take effect
      uc.Format("InsertAt: 0, Def: val = 'Outer: ' + val")
      Console.WriteLine(uc.EvalStr("10+20"))
      Console.WriteLine(uc.EvalStr("'Hello '+'world'"))
      Console.WriteLine(uc.EvalStr("5 > 10"))
      Console.WriteLine("---")
      
      '// This formatting will be the first one to take effect
      uc.Format("val = 'Inner: ' + val") '// Optionally InsertAt: -1 could have been used
      Console.WriteLine(uc.EvalStr("10+20"))
      Console.WriteLine(uc.EvalStr("'Hello '+'world'"))
      Console.WriteLine(uc.EvalStr("5 > 10"))
      Console.WriteLine("---")
      
      uc.FormatRemove()
      
      Console.WriteLine(uc.EvalStr("10+20"))
      Console.WriteLine(uc.EvalStr("'Hello '+'world'"))
      Console.WriteLine(uc.EvalStr("5 > 10"))
   End Sub
End Module
				
			
Answer: 30
Answer: String: <<Hello world>>
Bool: Answer: [[false]]
---
Outer: Answer: 30
Outer: Answer: String: <<Hello world>>
Outer: Bool: Answer: [[false]]
---
Outer: Answer: Inner: 30
Outer: Answer: String: <<Inner: Hello world>>
Outer: Bool: Answer: [[Inner: false]]
---
30
Hello world
false