SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Basic RoundUP question

    Hello all. I think I'm a bit dizzy this morning my mind is all over the place.

    Code:
    If netfare > 60 Then
    surcharge = netfare * 0.05
    Else
    surcharge = 3
    End If
    
    surcharge = Round(surcharge)
    I would like to round surcharge up to the nearest 1 (whole number)

    examples:

    if surcharge is 1.5 then should be 2
    if surcharge is 8.12 then surcharge should be 9

    Thank you in advance.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,269
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)
    I don't know if it's called the same for you, but in other languages there's
    round - to nearest whole int
    floor - to the lower whole int
    ceiling (or ceil) - to the higher whole int

  3. #3
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this

    surcharge = Round(surcharge + .4)

  4. #4
    SitePoint Addict itHighway's Avatar
    Join Date
    Jan 2008
    Location
    GUJ
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In classic ASP the only way to do it is:
    if cdbl(Surcharge) > clng(Surcharge) then
    Surcharge = clng(Surcharge) + 1
    end if


Bookmarks

Posting Permissions

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