I have double number and i want to approximate it always to the nearest .
for eg: 1.2324 -> 1 1.898 -> 2
how can i do this with C#?
I have double number and i want to approximate it always to the nearest .
for eg: 1.2324 -> 1 1.898 -> 2
how can i do this with C#?
Use Math.Round()
.
double d1 = Math.Round(1.2324); //d1 is 1
double d2 = Math.Round(1.898); //d2 is 2