Utilities > Custom Rounding Functions

Custom Rounding Functions

Article #: Product: Version:


The DMExpress Custom Function Framework allows users to write their own custom functions in C/C++, build them into a Unix/Windows 32/64 bit library, and seamlessly integrate them into DMExpress at both design and run time.

A set of math rounding functions, developed with the custom function interface, use the standard C/C++ math library floor and ceil functions to achieve a variety of common rounding algorithms and are provided as a plugin library for DMExpress.


The attached .cpp file and pre-built libraries use the DMExpress custom function interface to create the following set of math rounding functions, which can be made available in DMExpress by including the library in your DMExpress environment as described in Additional Information.

For each function, we display the signature as it appears in the DMExpress Task Editor, as well as the API function declaration as it appears in the .cpp file, where the macros around the input and output parameters define the respective data types as explained in Custom function interface in the DMExpress Help.

The provided functions treat their input values as double-precision floating point numbers, and the precision of floating point math is inherently limited.

Additionally, rounding results from some of the provided functions that perform floating point arithmetic (e.g. +/- 0.5) may be incorrect in rare edge cases, even when the input is a valid floating point number. This is due to accumulated floating-point inaccuracy when the input value is extremely close to the boundary between being rounded up and being rounded down.

Unlike the DMExpress Round() function, these functions do not accept a user-specified precision argument, so all results are rounded to the nearest whole integer.


396_RoundingFunctions.zip, which contains the RoundingFunctions.cpp file, 32 and 64 bit Windows .dll files, and a 64 bit Linux .so file

Additional Information

To use the attached pre-built library, simply copy the appropriate version for your OS to the <DMExpress>\Plugins folder, where <DMExpress> is the DMExpress installation directory, and restart the Task Editor if it's already running. The functions will appear in the Custom submenu of the Function dropdown menu in the Expression Builder and Condition Builder dialogs.

For more information on creating and building custom functions for DMExpress, and making them available in the DMExpress environment, see Custom function framework in the DMExpress Help.

Last updated: