Round function In QTP Not Working

ilga gracy

ilga gracy

@ilga-gracy-xmcbZ0 Oct 22, 2024
Its a great pleasure to join in this community to get involved with more engineers and sharing knowledge among us. I am working as an Analyst Programmer in Syntel. This is a good moment to share about me in this community. Moreover i am married.. i need some details in qtp..

If anybody knows qtp, help me... Round function is not working for the numbers 16.955, 17.955, 18.955 and 19.955 with 2 decimal places. it is giving the answer as 16.95, 17.95, 18.95 and 19.95 instead of 16.96, 17.96, 18.96 and 19.96.

Could anyone help me why is it showing like this?

Thanks,
Gracy

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Kaustubh Katdare

    Kaustubh Katdare

    @thebigk Jul 26, 2012

    Marking #-Link-Snipped-# & #-Link-Snipped-# . Can you guys help?
  • Saandeep Sreerambatla

    Saandeep Sreerambatla

    @saandeep-sreerambatla-hWHU1M Jul 26, 2012

    I think its returning the correct value only.
  • Saandeep Sreerambatla

    Saandeep Sreerambatla

    @saandeep-sreerambatla-hWHU1M Jul 27, 2012

    If it is 16.956 then Round(16.956,2) will give you 16.96.
  • ilga gracy

    ilga gracy

    @ilga-gracy-xmcbZ0 Jul 27, 2012

    English-Scared
    I think its returning the correct value only.
    no its not for 16.955. check it for 6.955. it will return the value as 6.96. but it is not returning for 16.955, 17.955, 18.955 and 19.955
  • Anil Jain

    Anil Jain

    @CrazyBoy Jul 27, 2012

    Which operating system are you using?
    Also, how you are using the Round Function?

    I vaguely remember that on Windows 7, Round Function works with both. decimal as well as , comma and that depends on the regional setting of the system. Check your regional setting at Control panel; check a little more around that.

    i meant if 16.955 is not working for you probably you have comma settings
    Try with,
    A = Round(16,955, 2)
    If you have settings that accept decimal than
    A = Round (16.955, 2) should return 16.96

    Let me know.

    -CB
  • KenJackson

    KenJackson

    @kenjackson-mBf7HF Jul 28, 2012

    Did you type in 16.955 and 17.955? Or are they the results of prior calculations?

    If a prior calculation returned 16.9547,
    then it will be correctly displayed as 16.955 when rounded to 3 places,
    but will also be correctly displayed as 16.95 when the rounding is changed to 2 places.

    Otherwise, I don't know qtp, but you should make sure the Round function is documented to work the way you think. I've found various counterintuitive surprises in function documentation before.
  • ilga gracy

    ilga gracy

    @ilga-gracy-xmcbZ0 Jul 29, 2012

    crazyboy
    Which operating system are you using?
    Also, how you are using the Round Function?

    I vaguely remember that on Windows 7, Round Function works with both. decimal as well as , comma and that depends on the regional setting of the system. Check your regional setting at Control panel; check a little more around that.

    i meant if 16.955 is not working for you probably you have comma settings
    Try with,
    A = Round(16,955, 2)
    If you have settings that accept decimal than
    A = Round (16.955, 2) should return 16.96

    Let me know.

    -CB
    I am using windows xp. it supports only decimal point. Even Though i am not getting the result only for those values 16,17,18 and 19. Check the uploaded file. It is showing proper result for 15 and 20. but not for the above mentioned values.
  • Anil Jain

    Anil Jain

    @CrazyBoy Jul 30, 2012

    ilga gracy
    I am using windows xp. it supports only decimal point. Even Though i am not getting the result only for those values 16,17,18 and 19. Check the uploaded file. It is showing proper result for 15 and 20. but not for the above mentioned values.
    Very Peculiar problem 😔
    I will research more on this and update the thread.

    -CB