4 Oct 2010 at 21:21 #1 Izi Izi Soldato Joined 9 Dec 2007 Posts 2,718 I have some decimals as follows: 117.56 117.7 117.63 117.55 I want to round them to 1 dp nearest to 0.5 I.E all of the above I want to be 117.5 Math.Round(decimal,1) just does 117.6, 117.7, 117.5 etc
I have some decimals as follows: 117.56 117.7 117.63 117.55 I want to round them to 1 dp nearest to 0.5 I.E all of the above I want to be 117.5 Math.Round(decimal,1) just does 117.6, 117.7, 117.5 etc
4 Oct 2010 at 21:36 #2 Izi Izi Soldato OP Joined 9 Dec 2007 Posts 2,718 actually think i figured this out: round to nearest integer taking off 0.5 then add 0.5.
4 Oct 2010 at 21:55 #3 Pho Pho Soldato Joined 18 Oct 2002 Posts 9,336 Location Derbyshire edit: wait, I misread . Last edited: 4 Oct 2010
5 Oct 2010 at 09:53 #4 Dj_Jestar Dj_Jestar Caporegime Joined 18 Oct 2002 Posts 29,493 Location Back in East London Code: var rounded = (Math.Round(aDecimal * 2, MidpointRounding.AwayFromZero)) / 2