Forum Discussion

Lora_P_'s avatar
Lora_P_
New Contributor
13 years ago

Math.round();

By some reason I have problem using Math.round(), C# script, TestComplete

In my test I calculate data to compare with the GUI value. Calculated data should be rounded to the nearest integer.



var total;

//calculate total

total=Math.round(total);



Looks like it doesn't recognize Math.round 

Can someone help with other solution.

The total is in format 167.45

Thanks!

3 Replies


  • Hello Larisa,



    Please clarify what you mean by "it doesn't recognize Math.round". Does an error occur? What is the value of total after using Math.round?







  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    I just attempted the following in TestComplete 8.60 using JavaScript





    function bladiddy()

    {

    var total = 123.456

    total = Math.round(total)

    Log.Message(total)

    }




    My log shows a value of 123 written to the log, no errors.  Passing in a string, an empty string, a null all works just fine.  If I include in the string non-numeric values, I don't get an error, but I get "NAN" in my log.



    So, it might be helpful to understand what sort of error, problem, etc., you're getting.  Could you put up the text of the error message(s) you're getting?
  • Lora_P_'s avatar
    Lora_P_
    New Contributor
    Thank you! Today it worked just fine with no changes made on my side.

    The message I hade before (something like this): Method doesn't exist, and, of couse it didn't calculate rounded total...