As you know due to genius rounding rule in C#
we are getting the following values:
decimal d = 2.155M;
var r = Math.Round(d, 2); //2.16
decimal d = 2.145M;
var r = Math.Round(d, 2); //2.14
Now on client side in Javascript
I am getting:
2.155.toFixed(2)
"2.15"
2.145.toFixed(2)
"2.15"
kendo.toString(2.155, 'n2')
"2.16"
kendo.toString(2.145, 'n2')
"2.15"
But I have validations in the backend that is failing due to this. What is the correct way to deal with this kind of situation? How can I sync C#
and Javascript
rounding to be sure they both round to the same values?