Round number

sterjo

Member
Joined
Aug 13, 2006
Messages
5
Programming Experience
Beginner
Uhm, not sure if it's the right place to post this, however I want to round a number in vb.net to the nearest half so 1.86 = 2, 1.35 = 1.50 but 1.50 stays 1.50 or 2.5=2.5. I had a formula for this, which i accedently deleted so Im lost. It was something like (number+number)*2/.... any ideas?
thx
 
look into the Math.Round() stuff

i believe it's overloaded so you can specify how many decimal places it'll round to
 
look into the Math.Round() stuff

i believe it's overloaded so you can specify how many decimal places it'll round to

Mmh, its not so much about to certain dp.. its about constraining it to the nearest X..

Might I suggest that you divide it by 0.5, round THE result and then multiply it by 0.5 again?
 
Back
Top