Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

How can I do extended maths calculations such as cosine, log and exponential in SilkTest?

How can I do extended maths calculations such as cosine, log and exponential in SilkTest?

Maths functions are currently not available within the 4Test proprietary language. There are many ways to perform this task, two of which are to use either Java (using the Silk4J eclipse plugin) and the math library within the Java language, or we can also use the math library available in the C/C++ language. The C/C++ language is advantageous as it allows us to create a dll which contains the math functions required, which in turn, we can call from SilkTest by calling the functions available in the dll file. This is available in the downloadable attachment Math.zip.

This archive contains the following files:

These files provide the cmath library functions to enable math functions to be used in SilkTest.

The functions available in the dll file are the functions available in the cmath library .
cmath declares a set of functions to compute common mathematical operations and transformations

Software Requirements:

Setup Instruction:

1. Extract the Math folder in the archive to the SilkTest installation directory


The following functions are available in Math.inc

_cos (double num)
_sin (double num)
_tan (double num)
_acos (double num)
_asin (double num)
_atan (double num)
_atan2 (double y, double x)

_cosh (double num)
_sinh (double num)
_tanh (double num)

_exp (double num)
_frexp (double num)
_ldexp (double num, int exp)
_In (double num)
_log10 (double num)
_log (double num, double base)
_modf (double num)

_pow (double base, double exp)
_sqrt (double num)

_ceil (double num)
_fabs (double num)
_floor (double num)
_fmod (double numerator, double denominator)

REAL Round (REAL rOriginal, INTEGER iPlaces optional)


Once the Math folder has been extracted to the SilkTest installation directory,
user can specify the Math.inc file in the SilkTest Runtime Options or within the Testscript file.

Specifying Math.inc in the SilkTest Runtime Options for usage across SilkTest project:
1. From SilkTest, goto Options | Runtime
2. In the "Use files" section, add "Math\Math.inc"

Specifying Math.inc in SilkTest Testscript file for usage in a single Testscript file:
1. Add the following line at the beginning of the Testscript file
use "Math\Math.inc"

Old KB# 29864


Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 20:40
Updated by:
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.