Results 1 to 4 of 4

Thread: rounding up number?

  1. #1

    Thread Starter
    Addicted Member Tengkorak's Avatar
    Join Date
    Nov 2006
    Posts
    240

    rounding up number?

    hi guys...
    i have problem about rounding up.
    this is my value 38495 . i want to rounding up that value to 38500.
    how to do that?

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: rounding up number?

    MsgBox -Int(-38495 / 100) * 100

    Int always rounds down, so by making a value negative it rounds it down making the value bigger (greater negative).

  3. #3

    Thread Starter
    Addicted Member Tengkorak's Avatar
    Join Date
    Nov 2006
    Posts
    240

    Re: rounding up number?

    ok thanks. but when the value is 38403 it become 38500. why ?

  4. #4
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: rounding up number?

    It always rounds up. If you don't want that, then you need a different kind of rounding.

    Bankers' rounding: MsgBox Round(38403 / 100, 0) * 100

    Regular rounding: MsgBox Int(38403 / 100 + 0.5) * 100

    The difference with bankers' and regular rounding is how they handle rounding numbers such as 0.5, 1.5, 2.5 - regular goes always up, bankers' goes up or down depending on whether the number is odd or even.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width