0

I have this Number

double Nb=4.9584763251

how can I make get only two digits after the comma without rounding the number :

Nb=`4.95` and not `4.96` 

using the Math.Round(Nb,2) will return 4.96 is there any way to fix this ?

Sora
  • 2,465
  • 18
  • 73
  • 146

2 Answers2

1

You may use Math.Truncate(Nb * 100) / 100m

MakePeaceGreatAgain
  • 35,491
  • 6
  • 60
  • 111
0
 double x = ((int)(Nb*100))/100.0
rkrahl
  • 1,159
  • 12
  • 18