Results 1 to 4 of 4

Thread: Rounding down

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2001
    Location
    UK
    Posts
    38

    Rounding down

    I have a var defined as double - I am using the round() function to set the resulting var to 1 dec place eg :

    TempCalc = round( 0.15 , 1 )

    Std VB setting is to round up to 0.2 - but is there a setting I can use to round down in this instance - ie the result I want is 0.1

    If the value is 0.16 - then yes, I do want it to rounded up to 0.2

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    subtract 0.01 from your variable before rounding it
    Mark
    -------------------

  3. #3
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    if it is 1.5 u should round up

  4. #4

    Thread Starter
    Member
    Join Date
    Sep 2001
    Location
    UK
    Posts
    38

    Wink

    You're not wrong - try telling my customer this !
    thanks for both comments, I've found a formula on another forum that seems to work it out :

    x = 0.015
    X = Int(X * 100 + 0.5) / 100

    returns 0.01

    if x = 0.016 then returns 0.02 - sweet

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