How to avoid round off

Hello,

i need to devide to cell values and need to do mu;tiplication by 100.

here i geed to get 185 and 185
and need to do (187/185)*100
when i am doing this , result is showing 100 but correct value is 98.9 which i need to compare with excel field shown in image.
i am using int variable to get values and genericvalue type for devide and multiplication like below

i need to avoid round off or wrng value.
help me on same.
my required ou is 98.9

Hi @Mathkar_kunal here you can use decimal or double instead of integer than you will get output. Try this hope it finds well

still giving same output
change v1,v2 variable type to double and final variable type keep same as generic tpe and that too checked by changing double
but same output
100

Hi @Mathkar_kunal

Please try to correct Variable types,

If you found helpful, feel free to tick as a solution.
Happy Automation

Hi @Mathkar_kunal

Try the below expression in assign activity,

(Cdbl(V1)/Cdbl(V2))*100

Make sure Final Variable is in System.double datatype.

Hope it helps!!


still getting 100

Okay @Mathkar_kunal

Try this one it’s working,

Math.Round((Cdbl(V1)/Cdbl(V2))*100, 2)

Happy Automation!!

@Mathkar_kunal
Can you debug and check the value of V1 and V2 that it is 185 and 187 ? just put a breakpoint before assigning the final

check this,

You shouldn’t be using GenericValue as a datatype. Use proper datatypes like Single, Double, Decimal, Int32, Int64, etc.

@Mathkar_kunal

  1. result and all other variables should be double
  2. 187/185 is never 98.9 may be you need to do otherway round

cheers

@Sanjay_Bhat
Pls check,

Or

Happy Automation!

1 Like

@Mathkar_kunal

Did you try solution given by @prashant1603765 ?

1 Like

yes tried now working

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.