Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRIS, see the InterSystems IRIS Adoption Guide and the InterSystems IRIS In-Place Conversion Guide, both available on the WRC Distributions page (login required).

Previous sectionNext section


Inverse (arc) cosine function.




Argument Description
n A signed decimal number.


$ZARCCOS returns the trigonometric inverse (arc) cosine of n. The result is given in radians (to 18 decimal places).



Signed decimal number ranging from 1 to -1 (inclusive). It can be specified as a value, a variable, or an expression. Numbers outside the range generate an <ILLEGAL VALUE> error. A non-numeric string is evaluated as 0.

The following are arc cosine values returned by $ZARCCOS:

1 returns 0
0 returns 1.570796326794896619
-1 returns pi (3.141592653589793238)


The following example permits you to compare the arc cosine and the arc sine of a number:

   READ "Input a number: ",num
   IF num>1 { WRITE !,"ILLEGAL VALUE: number too big" }
   ELSEIF num<-1 { WRITE !,"ILLEGAL VALUE: number too small" }
   ELSE { 
         WRITE !,"the arc cosine is: ",$ZARCCOS(num)
         WRITE !,"the arc sine is: ",$ZARCSIN(num)
Copy code to clipboard

The following example compares the results from Caché fractional numbers ($DECIMAL numbers) and $DOUBLE numbers. In both cases, the arc cosine of 1 is exactly 0:

  WRITE !,"the arc cosine is: ",$ZARCCOS(0.0)
  WRITE !,"the arc cosine is: ",$ZARCCOS($DOUBLE(0.0))
  WRITE !,"the arc cosine is: ",$ZARCCOS(1.0)
  WRITE !,"the arc cosine is: ",$ZARCCOS($DOUBLE(1.0))
  WRITE !,"the arc cosine is: ",$ZARCCOS(-1.0)
  WRITE !,"the arc cosine is: ",$ZARCCOS($DOUBLE(-1.0))
Copy code to clipboard

See Also

FeedbackOpens in a new window