xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

Cos()

Calculates the cosine for an angle.

Syntax

Cos( <nAngle> ) --> nCosine

Arguments

<nAngle>
A numeric value specifies the angle as a fraction (or multiple) of Pi().

Return

The function returns the cosine of an angle in the range between -1 and +1.

Info

See also:CosH(), Cot(), DtoR(), RtoD(), SetPrec(), Sin(), Tan()
Category: CT:Math , Mathematical functions , Trigonometric functions
Source:ct\trig.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example displays results of function Cos().

   PROCEDURE Main
      ? Str( Cos( -Pi()*1.0 ), 18, 15)  // result: -1.000000000000000
      ? Str( Cos( -Pi()*0.5 ), 18, 15)  // result:  0.000000000000000
      ? Str( Cos( -Pi()*0.3 ), 18, 15)  // result:  0.587785252292473
      ? Str( Cos(  Pi()*0.0 ), 18, 15)  // result:  1.000000000000000
      ? Str( Cos(  Pi()*0.3 ), 18, 15)  // result:  0.587785252292473
      ? Str( Cos(  Pi()*0.5 ), 18, 15)  // result:  0.000000000000000
      ? Str( Cos(  Pi()*1.0 ), 18, 15)  // result: -1.000000000000000
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe