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

Is there a function within SilkTest for rounding REAL numbers ?

Is there a function within SilkTest for rounding REAL numbers ?

There is no function within SilkTest for doing this but the following is a scripted function that will allow you to do this.

REAL Round ( REAL rNum, OPTIONAL INTEGER iPlaces)

rNum - Real number to be rounded
iPlaces - Number of decimal places to be rounded to.

[-] testcase Use_Round () appstate none
[ ]
[ ] // prints "3.142"
[ ] Print (Round (3.1415786, 3))
[ ]
[ ] // prints "3.890"
[ ] Print (Round (3.8899, 3))
[ ]
[ ] // prints "8.73"
[ ] Print (Round (8.7252123))
[ ]
[-] REAL Round (REAL rValue, INTEGER iPlaces optional)
[ ] REAL rRtn
[ ] STRING sVal
[ ]
[ ] // if no number of places is specified...
[-] if (iPlaces == NULL)
[ ]
[ ] // set it to 2
[ ] iPlaces = 2
[ ]
[ ] // use Str to get the rounded value
[ ] sVal = Trim (Str (rValue, 0, iPlaces))
[ ]
[ ] // convert it back into a real
[ ] rRtn = Val (sVal)
[ ]
[ ] // return rounded number
[ ] return rRtn

DISCLAIMER:

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 19:31
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.