Math round is not working

Dear all,

I am reading amounts from several documents with regex. After that I transform the string into Double type variable, but the decimals, if this one ends with 0, for example: 25,80, it gets me 25,8. So I tried math.round(var,2) to get 25,80, but it is not working. More over, if an amount is for example 25,55 it gets me 25,55. So I do not know how getting 25,80.

Can you help me?

Thanks! :slight_smile:

Thats how the double datatype works. the ending 0 is of no significance as the value remains the same.

You can switch it to Decimal instead.
convert.ToDecimal(“25.80”)

Or else, if you want to convert your double back to a string to type somewhere, you’d do something like
convert.ToDouble(“25.80”).ToString("#.00")

image