Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

rounding numbers

rounding numbers

i was wondering if someone could tell me how to round numbers with decimals to a whole number

RE: rounding numbers

Look in the help files for INT() function.

RE: rounding numbers

INT() always rounds the number down.
If you want it to round as a normal human would round such as 4.5 to 5 instead of what Qbasic would do and round 4.5 to 4 then just add .5


If you wanted to round like a normal human then you would
Answer is 5

Or just round like the computer would
Answer is 4

RE: rounding numbers

a = 4.55
IF a > INT(a) + .5 THEN
   a = INT(a) + 1
   a = INT(a)

RE: rounding numbers

Since QB4.5 doesnt have a currency floating point type here
is what I did.

DIM Dollar as long
DIM Cents as integer
DIM Amount as double

input amount
print Dollar;".";Cents
print using "##,###.##";Dollar+cents/100

this can also be stored in 5 bytes using mkl$ and chr$

one Caveat: you need to check for negative cents before
using chr$(cents)

If Cents<0 then Dollar=Dollar-1:Cents=Cents+100

then to get them back

RE: rounding numbers

To round like a human, use the CINT() function.  On extremely large numbers, using CINT() will give you an error.  That is why most people use the INT() function whenever possible.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close