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.

ValueDbl(double)

Method

Product: 

Fast Math Parser

Class: 

Item

Sets the value of a uCalc Item, but only if its data type is double-precision floating-point.

Syntax

ValueDbl(double)

Parameters

value
double
The double-precision floating-point value to assign to the variable.

Return

void

This method does not return a value.

Remarks

ValueDbl(double) is a type-safe method for setting the value of a uCalc Item, such as a variable. It will only succeed if the target item's underlying data type is Double.

Strict Typing vs. Flexible Conversion

It is crucial to understand the difference between this method and the more general Value() setters:

  • ValueDbl(double) (Strict): This method requires the variable to already be a Double. If you attempt to use it on a variable of another type (e.g., Integer or String), the operation will fail silently, and the variable's value will not be changed.

  • Value(double) or Value(string) (Flexible): The generic Value setters are more lenient. They will attempt to coerce or convert the input to the variable's target type. For example, calling myIntItem.Value(5.5) would successfully truncate the double and store 5 in the integer variable.

Use ValueDbl(double) when you need to guarantee type integrity and prevent accidental data loss or type conversions.

💡 Comparative Analysis

In a compiled language like C#, attempting to assign a double to an int variable without an explicit cast is a compile-time error. uCalc is a dynamic engine, so these checks happen at runtime. The ValueDbl method provides a programmatic way to enforce this type safety.

This is a critical feature for preventing logical errors in complex calculations where mixing data types could lead to unexpected results (e.g., loss of precision). By using the type-specific setters, you opt into a safer, more predictable way of manipulating variables programmatically.

Examples