R. E. Cook
Home 
Contact Us 

Dr. Cook
Resume 

RunningShoes Library for WinRunner 
RunningShoes 

Custom WinRunner Functions 
and Utilities,
to Your Specs
Custom 

A Random Collection of WinRunner Solutions
Solutions 

Creating DLLs for WinRunner 
"DLLs Demystified" 
(Mercury Interactive's Worldwide Users Conference 2000)

Calculate the integer portion of ANY input value.

 

WinRunner's int(x) function is defined to work when x > 0. It returns an incorrect value when x < 0.  The Integer() function here works correctly over all x, so it corrects the problem in int(). In addition, the function has built-in protection in case Mercury fixes the error in a future release.

The problem with the int() function is that it apparently rounds the input down, instead of taking the integer portion of the input. That works okay with positive input, but with negative input, it returns the next lower integer.

For example, the integer portion of -5.5 is -5. However, int(-5.5) returns -6, since it rounds down. The function here returns the correct value: Integer(-5.5) returns -5.

The code is in a text file to avoid the display mangling that browsers tend to do to normal pages. View Integer.txt.



Top of  This Page | R. E. Cook Home Page

Copyright R. E. Cook Consulting, 2000 - 2011.
All rights reserved.

The site is designed to look best when viewed with Internet Explorer 5.0 - 8.0. Results with other browsers will probably deviate from what is intended.

NOTE: This website refers to registered trademarks and service marks that are owned by other companies, including Mercury Interactive, WinRunner, TestDirector, TSL, Microsoft, Windows.