Results 1 to 7 of 7

Thread: Rounding

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Posts
    225
    How do I round to the nearest 0.5?

    eg. I have the number 0.6, how do I round it to 0.5? Or 0.8 to 1? 0.6 to 0.5?

    Thanks.

    -Git

  2. #2
    Member
    Join Date
    Jan 1999
    Location
    Skudeneshavn, Norway
    Posts
    38


    try this

    MyNumber = Int(MyNumber)

    Chris Davidsen
    Christian Davidsen

    If you go to sleep with an itchy
    ass, you wake up with smelly fingers.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Posts
    225
    Nope, that's not quite what I want. I want it to round to the nearest 0.5.

    So 0.7 would goto 0.5, 0.9 would goto 1, 0.3 would goto 0.5, 0.1 would goto 0, etc...

    Thanks anyway.

    -Git

  4. #4
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    If you use VB6 you can use the Round function to round a number...
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Posts
    225
    Nope - I meant so it will round in intervals of 0.5, not 1.

    I've figured it out now anyway.

    -Git

  6. #6
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    How did you managed that? I want to see because I'm unsure of you're trying to acomplish, it may be handy for me sometime!
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  7. #7
    Hyperactive Member dsy5's Avatar
    Join Date
    Jul 2000
    Location
    Lockport, NY
    Posts
    362
    You can try
    Code:
    Fix(number) + 0.5
    Unfortunately all these round down, so 0.9 is 0.5.

    Have a look at these threads:

    http://forums.vb-world.net/showthrea...threadid=28747
    http://forums.vb-world.net/showthrea...threadid=27446
    Donald Sy - VB (ab)user

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