Set Variable Value for integers round floats up?
if S1 and S2 are strings and I have a local variable x which is an integer in a keyword test
then if I call "Set Variable Value" for x and set it to the code expression aqConvert.StrToFloat(S1) / aqConvert.StrToFloat(S2)
I have noticed this rounds up instead of casting down which is what I'd expect. That is for simplicity S1 = "3.0000" and S2 = "5.0000"
then x = 1 instead of x = 0 which is what I'd expect.
Is there a way to make this what I'd expect? I tried Math.Trunc(...), Math.Int(...) both of which does not seem to exist, unlike Math.random() which does.
I'm using testcomplete 7.20 right now and cannot upgrade as I have a release to validate. Also I want to keep it a keyword test for now.
Re: Set Variable Value for integers round floats up?
You need to use the Math.floor method:
<font class="small">Code:</font><hr /><pre>Math.floor(aqConvert.StrToFloat(S1) / aqConvert.StrToFloat(S2))</pre><hr />