INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

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!

*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

round Cosine

round Cosine

(OP)
was making qbasic calculator... one choice is cos(number) and for the cos functions i use cos(number) and no matter what number i use the answer is one. I take it that the answer is too many digits long (prob nonteminating) and it rounds to an integer, however i would like it to round to say 6 decimal places to the left, eg. 5.234322 etc. How is this possible?

RE: round Cosine

HI,

So what number are you using?

In general the number should be ....

(Degree * pi / 180)

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: round Cosine

Again, what number are you using that, "the answer is one."?

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: round Cosine

(OP)
oh i get it

The answer is any number does that. Absolutely any number.

RE: round Cosine

(OP)
sorry, i just got back from work and it was a crappy day and im TIRED :o

RE: round Cosine

One test point is 60 degrees. COS should be .5 IIRC.

COS multiplier will never exceed 1 since the formula is adj/hyp.

Ed Fair
Give the wrong symptoms, get the wrong solutions.

RE: round Cosine

(OP)
i tried 60 degrees and it still says "1". ill paste the part of the code with the COS function

117 IF choice = 11 THEN PRINT "please enter your number"
IF choice = 11 THEN DIM csintimes
IF choice = 11 THEN INPUT csintimes
IF choice = 11 THEN LET p = csintimes
IF choice = 11 THEN LET a = COS(sintimes)
IF choice = 11 THEN PRINT "The answer is"; a
118 IF choice = 11 THEN PRINT
IF choice = 11 THEN PRINT "(1) exit the program"
IF choice = 11 THEN PRINT "(2) do more calculations"
IF choice = 11 THEN PRINT "(3) go back to the main menu"
IF choice = 11 THEN DIM cfpichoice
IF choice = 11 THEN INPUT cfpichoice
IF choice = 11 AND cfpichoice > 3 THEN PRINT "invalid number"
IF choice = 11 AND cfpichoice > 3 THEN GOTO 118
IF choice = 11 AND cfpichoice = 1 THEN STOP
IF choice = 11 AND cfpichoice = 2 THEN GOTO 117
IF choice = 11 AND cfpichoice = 3 THEN GOTO 100

The if choice = 11 things are there because choice 11 would trigger COS function.

RE: round Cosine

Exactly what did you enter as the argument for cos? What is the value of sintimes?

I'd expect the value to be:

1.04719 = 60 * 3.14159 / 180

Did you intend the input variable to be in csintimes?

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: round Cosine

Based on your code, I know you are still learning to use QB.

You will need to have a " DOUBLE-LONG " variable memory space. PLEASE NOTE: this will eat up some of your 65k memory allocation to QB...use it sparingly or RE-use a common D-Long variable through-out your program AS NEEDED. (yes you can use " Single-Long " var however in the future you may need a double so why not start now?)

-->in QB's HELP menu select "DATA TYPES" and it will show you the ranges available.

-->in your code you'd have to fix a few things (note the changes in RED)

117 IF choice = 11 THEN PRINT "please enter your number"
IF choice = 11 THEN DIM csintimes#
IF choice = 11 THEN INPUT csintimes#
IF choice = 11 THEN LET p = csintimes
IF choice = 11 THEN LET a# = COS(csintimes#) <--This is a typo
IF choice = 11 THEN PRINT "The answer is"; a#
118 IF choice = 11 THEN PRINT

-->Good Luck and Good Reading, MiggyD


After pondering the riddle (for many years I might add) I finally got the answer (inadvertently through a movie): "If a tree falls in the forest and no one is around, does it make a sound?"

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!

Resources

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