Prev: Design question
Next: Unmanaged code interop!
From: Raj on 29 Jan 2010 02:48 How do I round up a number to the nearest 0.05?
From: Peter Duniho on 29 Jan 2010 02:58 Raj wrote: > How do I round up a number to the nearest 0.05? http://www.lmgtfy.com/?q=c%23+round+up
From: Kosmo on 29 Jan 2010 04:43 On Jan 29, 8:48 am, Raj <R...(a)discussions.microsoft.com> wrote: > How do I round up a number to the nearest 0.05? What do you mean? Could you specify the rules you use to do that? for example, 100.251 - 100.253 ~ 100.250 100.254 - 100.256 ~ 100.255 100.257 - 100.259 ~ 100.260 is it what you suppose to have?
From: vanderghast on 29 Jan 2010 07:44 .... but for answers there ...like 1+ Math.Floor(x) , and even a long discussion about why (int)(x + 0.4) is better than (int) ( x+ 0.5) , with some sites where you have to "pay" to see the 'certified solution(s)' !! Math.Floor( 0.5 + 20*x) / 20.0 to round-to-the-nearest 1/20, not necessary up, and that, for positive values of x. To round-up-to the next 1/20 (unless it is already an exact 1/20), rather use Math.Ceiling( 20*x ) / 20.0 It may also be a technical problem about what it really does for x a floating point number, since technically it makes sense for decimal number, but for a float...? Finally, it may not be in agreement with banks policy, which don't systematically round someInt + 0.5 always up to the someInt+1 (they would lose money, given the large amount of rounding operations they perform). Vanderghast, Access MVP "Peter Duniho" <no.peted.spam(a)no.nwlink.spam.com> wrote in message news:OPwySjLoKHA.3664(a)TK2MSFTNGP04.phx.gbl... > Raj wrote: >> How do I round up a number to the nearest 0.05? > > http://www.lmgtfy.com/?q=c%23+round+up
From: Gregory A. Beamer on 29 Jan 2010 17:43
"Peter Duniho" <no.peted.spam(a)no.nwlink.spam.com> wrote in message news:OPwySjLoKHA.3664(a)TK2MSFTNGP04.phx.gbl... > Raj wrote: >> How do I round up a number to the nearest 0.05? > > http://www.lmgtfy.com/?q=c%23+round+up While I agree with the tack you are sailing on, C# round up does not answer the user's question. -- Peace and Grace, Greg Twitter: @gbworld Blog: http://gregorybeamer.spaces.live.com ************************************************ | Think outside the box! | ************************************************ |