CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 1999
    Posts
    4

    Rounding Numeric Values



    Hi there,


    I need codes on how to round up or down a numeric value.


    eg. 223.56 ==> 223 (round down)

    223.56 ==> 224 (round up)


    really need it for a project.

    wil lreally appreciate your help.

    thanks.


    eddy

    [email protected]

  2. #2
    Join Date
    Apr 1999
    Posts
    4

    Re: Rounding Numeric Values



    Hello Eddy,


    Here's what I found.


    Int - always rounds down.

    CInt and CLng - round to the nearest integer (for ex., 1.51 they will round up while 1.49 they will round down).


    I guess you'll have to write something of your own (but probably something very small) if you need to always round up.


    Good luck.

    Maria.

  3. #3
    Join Date
    Apr 1999
    Posts
    2

    Re: Rounding Numeric Values



    Simple, if CInt always rounds up with 1.50 and down with 1.49

    and you want it to always round up, just add 0.5 to your value before using CInt

    and if you want to always round down, just subtract 0.5 before using CInt.



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

Featured