Skip to content

COS

Source: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgCos Last revised: 2018-04-16

Returns the cosine of an angle.

Syntax

declare function Cos ( byval angle as double ) as double

Usage:

result = Cos( angle )

Parameters

  • angle — The angle, in radians.

Return Value

Returns the cosine of angle as a Double in the range -1.0 to 1.0.

Description

The argument angle is measured in radians (not degrees).

The value returned is undefined for values of angle with an absolute value of 2^63 or greater.

Cos can be overloaded as an operator to accept user-defined types.

Examples

vb
Const PI As Double = 3.1415926535897932
Dim a As Double
Dim r As Double
Input "Please enter an angle in degrees: ", a
r = a * PI / 180    'Convert the degrees to Radians
Print ""
Print "The cosine of a" ; a; " degree angle is"; Cos ( r )
Sleep

Output:

Please enter an angle in degrees: 30
The cosine of a 30 degree angle is 0.8660254037844387

Differences from QB

  • None.

See Also

Translated from FreeBASIC official docs. Contact us for removal if infringed.
FreeBASIC is an open-source project, not affiliated with Microsoft