Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 1677
Number of posts: 4766

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Edit Report
trig functions in Qbasic Posted by Lew on 13 Dec 2000 at 4:58 PM
I have 2 questions:<br>
1) I just noticed that the trig functions in Qbasic are not accurate or correct. For example the true sine of 45 degrees is .707... but when I ask that sin(45) be displayed it gives .850... Why is this? Am I doing something wrong, or using incorrect syntax? Is this a bug in Qbasic?<br>
<br>
2) If question #1 is answered/solved, then what is<br>
the correct syntax or format to get the inverse displayed? (From .707 etc.. back to 45 degrees)?<br>
A book that I have on Qbasic says that the command ATN is available. This should mean that if I enter ATN(.4567) for example, the displayed result should be 24.546... (answer in decimal degrees).<br>
<br>
Thanks for any help you can give. --- Lew<br>
<br>



Edit Report
Re: trig functions in Qbasic Posted by KDivad Leahcim on 14 Dec 2000 at 2:10 AM
: ...Is this a bug in Qbasic?<br>
<br>
It also shows as .850 in QuickBasic 4.5, VBDOS Pro, VB3 and VB5 Pro. Calc.exe does show .707, though. If it's a bug in QB, then it's apparently a bug in all of Microsoft's basic languages.<br>
<br>
: A book that I have on Qbasic says that the command ATN is available. This should mean that if I enter ATN(.4567) for example, the displayed result should be 24.546... (answer in decimal degrees).<br>
: <br>
<br>
You need to convert ATN's output from rads to degrees. <b>* (pi / 180)</b> You can get pi using <b>4 * ATN(1)</b>.<br>
Do you need a specific function to get from Atn to Sin? VB5's help file has a decent sized list (20) of Derived Math Functions dealing with Sin, Cos, Tan and their 1/x functions.


Edit Report
Re: Re: trig functions in Qbasic Posted by Dick on 28 Dec 2000 at 5:55 AM
: : ...Is this a bug in Qbasic?
:
: It also shows as .850 in QuickBasic 4.5, VBDOS Pro, VB3 and VB5 Pro. Calc.exe does show .707, though. If it's a bug in QB, then it's apparently a bug in all of Microsoft's basic languages.
:
: : A book that I have on Qbasic says that the command ATN is available. This should mean that if I enter ATN(.4567) for example, the displayed result should be 24.546... (answer in decimal degrees).
: :
:
: You need to convert ATN's output from rads to degrees. <b>* (pi / 180)</b> You can get pi using <b>4 * ATN(1)</b>.
: Do you need a specific function to get from Atn to Sin? VB5's help file has a decent sized list (20) of Derived Math Functions dealing with Sin, Cos, Tan and their 1/x functions.
:
Hi,
Try this program

pi# = 3.141592653589793# '# makes the numbers double precision
dtor# = pi# / 180# 'degrees to radians conversion factor

s# = SIN(45# * dtor#)
PRINT s#

The value is pretty close.

Dick


Report
Re: trig functions in Qbasic Posted by Puzzler on 31 May 2001 at 5:10 PM
All trig functions are in radians.

test it with:

pi# = 3.141592653589793

Print sin(pi# / 4)




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.