uCalc API Version: 5.7.0-preview.1 Released: 7/30/2026
Warning
uCalc API Preview Release Notice:This preview documentation describes the intended behavior of the API. It is not fully accurate or complete.The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.Use of the preview version in your production code is not recommended.
Product:
Class:
Sets the value of a uCalc Item, but only if its data type is double-precision floating-point.
This method does not return a value.
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.
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.
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.