Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

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.

shanley06 (Programmer)
16 Dec 02 15:02
i was wondering if someone could tell me how to round numbers with decimals to a whole number
MiggyD (Programmer)
16 Dec 02 15:14
Look in the help files for INT() function.
Great008 (Programmer)
6 Mar 03 1:01
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

a=4.5

If you wanted to round like a normal human then you would
a=a+.5
PRINT INT(a)
Answer is 5

Or just round like the computer would
PRINT INT(a)
Answer is 4
qbasicking (Programmer)
6 Mar 03 8:51
a = 4.55
IF a > INT(a) + .5 THEN
   a = INT(a) + 1
ELSE
   a = INT(a)
END IF
PRINT a
Buff1 (Programmer)
6 Mar 03 14:24
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
Dollar=Amount
Cents=(Amount-Dollar)*100
print Dollar;".";Cents
print using "##,###.##";Dollar+cents/100

this can also be stored in 5 bytes using mkl$ and chr$
amt$=msk$(Dollar)+chr$(cents)

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
Dollar=CVL(mid$(amt$,1,4))
Cents=asc(mid$(amt$,5,1))

quebasic2 (Programmer)
6 Mar 03 20:43
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.

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!

Back To Forum

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