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.

Arg2

Method

Product: 

Fast Math Parser

Class: 

Callback

Retrieves the second argument passed to a callback function as a double-precision number.

Syntax

Arg2()

Parameters

[None]

Return

double

The second argument as a double-precision floating-point number. Returns 0 if fewer than two arguments were passed.

Remarks

The Arg2() method is a high-performance shortcut for retrieving the second argument passed to a callback function. It is functionally identical to calling Arg(2) but avoids the overhead of passing an index, making it slightly more efficient.

This method is primarily a convenience for callbacks linked to binary operators or functions that take exactly two numeric arguments. It complements Arg1(), which retrieves the first argument.

Data Type

Arg2() specifically retrieves the argument as a double. If you need to access arguments of other types, use the corresponding type-safe methods:

💡 Why uCalc? (Comparative Analysis)

In many languages like C# or C++, a callback or delegate signature explicitly names its parameters:

// Standard C# delegatepublic delegate double MathOperation(double operand1, double operand2);

uCalc uses a different architectural pattern. The callback receives a single, unified Callback object (cb), and you use methods like Arg1() and Arg2() to retrieve arguments by position from that object. This model offers several advantages:

  • Flexibility: A single callback function can be registered to handle multiple uCalc functions or operators, even those with different numbers of arguments. The callback can use ArgCount() at runtime to determine how it was called.
  • Metaprogramming: This object-based approach allows the callback to access rich metadata about the arguments via methods like ArgItem() or ArgExpr(), which is not possible with simple value parameters.

Examples