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
So what number are you using?
In general the number should be ....
(Degree * pi / 180)
Skip,
Just traded in my OLD subtlety...
for a NUance!
RE: round Cosine
i attatched BAS file of the source code you can view with qbasic and suggest improvement :)
RE: round Cosine
Skip,
Just traded in my OLD subtlety...
for a NUance!
RE: round Cosine
The answer is any number does that. Absolutely any number.
RE: round Cosine
RE: round Cosine
Skip,
Just traded in my OLD subtlety...
for a NUance!
RE: round Cosine
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
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
I'd expect the value to be:
1.04719 = 60 * 3.14159 / 180
Did you intend the input variable to be in csintimes?
Skip,
for a NUance!
RE: round Cosine
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?"