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.

ValueSng(float)

Method

Product: 

Fast Math Parser

Class: 

Item

Sets the value of a variable that was defined with the 'Single' (32-bit float) data type.

Syntax

ValueSng(float)

Parameters

value
float
The single-precision floating-point value to assign to the variable.

Return

void

This method does not return a value.

Remarks

This method sets the value of a uCalc variable that was specifically defined as a Single (a 32-bit floating-point number).

It is the type-safe and recommended way to update single-precision variables from your host application. The variable must first be created using a method like DefineVariable, explicitly specifying the type:

var myFloat = uc.DefineVariable("myFloat As Single");myFloat.ValueSng(1.23);

Comparative Analysis

  • vs. Value(string): You could set the value using the generic string-based Value("1.23"), but ValueSng is more efficient. It avoids the overhead of parsing and evaluating a string, passing the native float value directly to the engine.

  • vs. Direct Memory Binding: For maximum performance in C++ or unsafe C#, you can bind a uCalc variable directly to a host variable's memory address when calling DefineVariable. This creates a live link, eliminating the need for setter methods entirely. ValueSng provides a safe, cross-platform alternative that does not require direct memory manipulation.

Examples