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.

ValueDbl()

Method

Product: 

Class: 

Retrieves the value of a uCalc Item, such as a variable, only if its data type is double-precision floating-point.

Syntax

ValueDbl()

Parameters

[None]

Return

double

Returns the item's double-precision floating-point value. Returns 0 if the item's data type is not Double.

Remarks

ValueDbl() is a type-safe accessor that retrieves the value of a uCalc Item if and only if its underlying data type is Double. It is the strict counterpart to the more general-purpose Value() method.

Strict Typing vs. Flexible Conversion

It is crucial to understand the difference between ValueDbl() and the generic Value():

  • ValueDbl(): This method is strict. It will only return a meaningful value if the Item's data type is Double. If called on a variable of a different type (e.g., Integer, String), it will return 0 or an otherwise invalid value without attempting a conversion.

  • Value(): This method is flexible. It defaults to returning a double and will actively attempt to coerce other types into a double (e.g., an Integer 123 becomes 123.0, a Boolean true becomes 1.0).

Choose ValueDbl() when your logic requires strict type safety and you want to ensure you are only working with double-precision floating-point numbers.

💡 Comparative Analysis

In a compiled language like C#, attempting to read an int as a double without an explicit cast is a compile-time error. uCalc, being a dynamic engine, handles this at runtime. The ValueDbl() method provides a way to enforce similar type safety within the uCalc environment.

  • Safe Approach (ValueDbl): Guarantees you are retrieving a Double. Use this when the precision and type are critical.
  • Convenient Approach (Value): Useful when you need a numeric representation of any variable and are comfortable with implicit type conversions.

To retrieve a variable's handle, use the ItemOf() method.

Examples