Cosine function.
An angle in radians ranging from Pi to 2 Pi (inclusive). It can be specified as a value, a variable, or an expression. You can specify the value Pi by using the
$ZPI special variable. You can specify positive or negative values smaller than Pi or larger than 2 Pi; Caché resolve these values to the corresponding multiple of Pi. For example, 3 Pi is equivalent to Pi, negative Pi is equivalent to Pi, and zero is equivalent to 2 Pi.
A non-numeric string is evaluated as 0.
READ "Input a number: ",num
IF $ZABS(num)>(2*$ZPI) { WRITE !,"number is a larger than 2 pi" }
ELSE {
WRITE !,"the cosine is: ",$ZCOS(num)
}
QUIT
The following example compares the results from Caché fractional numbers (
$DECIMAL numbers) and
$DOUBLE numbers. In both cases, the cosine of 0 is exactly 1, the cosine of pi is exactly -1:
WRITE !,"the cosine is: ",$ZCOS(0.0)
WRITE !,"the cosine is: ",$ZCOS($DOUBLE(0.0))
WRITE !,"the cosine is: ",$ZCOS(1.0)
WRITE !,"the cosine is: ",$ZCOS($DOUBLE(1.0))
WRITE !,"the cosine is: ",$ZCOS($ZPI)
WRITE !,"the cosine is: ",$ZCOS($DOUBLE($ZPI))