SIN
 
Syntax


#include <FREQOUT.bas>                            ' source in /Program Files/Coridium/BASIClib

FUNCTION SIN ( number )      ' declared in FREQOUT.bas

Description

ARMbasic uses integers, but there may be a need for certain functions that normally use floating point calculations.  One of these is the sine function, which normally operates on degrees or radians.  But for simplicity and the binary world, these values and the result value have been normalized to fit in a byte value. So rather than taking an argument of 0..359 or 0..2 p , the argument is 0-255 which is equal to the number of degrees times 0.7103  (256/360).   The result would normally be between -1 and 1, but in this case it is expressed as -127 to +127 or the sin() multiplied by 127.
Example

PRINT "Please enter an angle in degrees: ";
DEBUGIN a
r = a * 256 / 360        'Convert the degrees to Radians
PRINT ""
PRINT "The sine of a" ; a; " degree angle is"; SIN ( r )
END


The output would look like:
Please enter an angle in degrees: 30

The sine of a 30 degree angle IS 64

Differences from otber BASICs

See also