ValueSng(float)

Method

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

Product: 

Class: 

Warning

uCalc API Preview Release Notice:The uCalc engine has successfully transitioned to modern cross-platform environments.The next phase envolves some structural changes, performance optimizations, and API refinements.The API is subject to breaking changes prior to the stable release. Please evaluate the preview version thoroughly before production use.

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

This page last modified on: 

8/21/2026