trig functions in Qbasic - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

trig functions in Qbasic

I have 2 questions:

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?



2) If question #1 is answered/solved, then what is

the correct syntax or format to get the inverse displayed? (From .707 etc.. back to 45 degrees)?

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).



Thanks for any help you can give. --- Lew






Comments

  • : ...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. * (pi / 180) You can get pi using 4 * ATN(1).

    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.


  • : : ...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. * (pi / 180) You can get pi using 4 * ATN(1).
    : 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


  • PuzzlerPuzzler Posts: 208Member
    All trig functions are in radians.

    test it with:

    pi# = 3.141592653589793

    Print sin(pi# / 4)

Sign In or Register to comment.