IMPORTANT NOTICE: As of 21 February, anything posted in this community WILL NOT BE MIGRATED to our new community site. We have pulled all user information and data from this site and are now in an approximately week long process of importing users, roles, and data to our new site. We are leaving this site open and active so you can post and hopefully get a response until the migration is complete. Once complete, the URL that currently takes you to this site will take you to our new site so your bookmarks will work as always. Please read the information on a New Login Process
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