Re: Rounding to nearest 1000

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi John,

Maybe irrelevant to poster,
but both will produce banker's rounding...

gary

"John Spencer" wrote:
CInt is not the same as Int.
CInt rounds the number to the nearest whole number value (using bankers
rounding).
Int truncates the number - returns just the integer portion.

One change to Ken Snell's suggestion: I would use CLng since CInt is
limited
to handling numbers in the range 32267 (plus or minus).


"Darrell" <dcyphers@xxxxxxx> wrote in message
news:u0Kk7daxGHA.3788@xxxxxxxxxxxxxxxxxxxxxxx
Ken Snell (MVP) wrote:
CInt(YourNumber / 1000) * 1000


Thank you, Ken. The only catch is that, unless I misunderstand this, I'm
going to get the next LOWER 1000, rather than the NEAREST 1000. If
MyNumber is 3900, dividing by 1000 will give me 3.9. CInt will give me
3,
and multiplying by 1000 will give me 3000. What I would like in this
case
is 4000.

Darrell




.



Relevant Pages

  • Re: Rounding to nearest 1000
    ... CInt is not the same as Int. ... CInt rounds the number to the nearest whole number value (using bankers ... rounding). ... Int truncates the number - returns just the integer portion. ...
    (microsoft.public.access.queries)
  • Re: INT() vs CInt()
    ... > To my mind, these two perform an identical function. ... Either may be preferable depending on the need; CInt() returns an Integer ... rounding issue usually trumps that concern. ...
    (microsoft.public.vb.general.discussion)
  • Re: Random integer formula?
    ... Rick pointed out, for which you would need to use CInt, but like he says, I'm ... you're rounding down, you would need to add one otherwise you'd never get the ... Mine is correct if you're using CLng (or CInt as Rick said to avoid banker's ...
    (microsoft.public.vb.general.discussion)
  • Re: Rounding
    ... What Microsoft calls "Banker's Rounding" (for reasons that are unclear to ... rounding method specified by the ASTM standard, that rounds to the nearest ... For example, 2500000 would round ... I want to use bankers rounding on a number. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Random integer formula?
    ... Sorry - I discovered that CInt does do banker's rounding, ... thought when writing my previous replyl to your post. ...
    (microsoft.public.vb.general.discussion)