Rounding up

Discussion in 'Programming General' started by 5cript, Apr 13, 2007.

Rounding up
  1. Unread #1 - Apr 13, 2007 at 3:53 PM
  2. 5cript
    Joined:
    Jan 22, 2007
    Posts:
    138
    Referrals:
    1
    Sythe Gold:
    0

    5cript Active Member

    Rounding up

    I just need a code for rounding up in visual basic. If there isnt is there someother way i could? (BTW, my code i mean a symbol) Here is what im trying to do
    Code:
    (aa - b) /f 
    when im calculating it, it ends in .13 for example and i want it to round up no matter what it ends in. Thanks for your help!
     
  3. Unread #2 - Apr 13, 2007 at 5:34 PM
  4. speljohan
    Joined:
    Apr 24, 2005
    Posts:
    1,450
    Referrals:
    3
    Sythe Gold:
    0

    speljohan Guru
    Visual Basic Programmers

    Rounding up

    declare the variable as a Single instead of an integer.
     
  5. Unread #3 - Apr 13, 2007 at 5:36 PM
  6. dodge
    Joined:
    Mar 26, 2007
    Posts:
    125
    Referrals:
    1
    Sythe Gold:
    5

    dodge Active Member
    Banned

    Rounding up

    somthign like

    Math.Round(6.69696969 - 0.005, 2)

    For the generic case:

    Function Truncate(ByVal value As Double, ByVal decimals As Integer) As Double

    Return Math.Round(value - 0.5 / Math.Pow(10, decimals), decimals)

    End Function



    also you can use some formatting

    take a look at this

    http://msconline.maconstate.edu/tutorials/VBNET/VBNET01/vbnet01-08.aspx
     
  7. Unread #4 - Apr 13, 2007 at 8:31 PM
  8. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Rounding up

    round()
    int()
     
  9. Unread #5 - Apr 14, 2007 at 6:29 AM
  10. speljohan
    Joined:
    Apr 24, 2005
    Posts:
    1,450
    Referrals:
    3
    Sythe Gold:
    0

    speljohan Guru
    Visual Basic Programmers

    Rounding up

    don't use the functions covey suggested. They're vb6 functions and work very slowly compared to the built in functions of the framework.
     
< Ceating dlls | need tutorial lesson!! >

Users viewing this thread
1 guest


 
 
Adblock breaks this site