docs.intersystems.com
Home  /  Application Development: Core Topics  /  ObjectScript Reference  /  ObjectScript Functions  /  $ZTAN


ObjectScript Reference
$ZTAN
[Back]  [Next] 
InterSystems: The power behind what matters   
Search:  


Returns the trigonometric tangent of the specified angle value.
Synopsis
$ZTAN(n)
Parameter
n An angle in radians ranging from Pi to 2 Pi (inclusive). Other supplied numeric values are converted to a value within this range.
Description
$ZTAN returns the trigonometric tangent of n. The result is a signed decimal number.
Note:
$ZTAN (like all trigonometric functions) calculates its values based on pi rounded to the number of available decimal digits. Therefore, the value returned by $ZTAN($ZPI) is –.000000000000000000462644 and $ZTAN(–$ZPI) is .000000000000000000462644. For this reason you should not perform limit tests comparing these returned values to 0. $ZTAN(0) is 0.
Parameter
n
An angle in radians ranging from 0 to 2 Pi. It can be specified as a value, a variable, or an expression.
A non-numeric string is evaluated as 0.
Examples
The following example permits you to compute the tangent of a number:
   READ "Input a number: ",num
   WRITE !,"the tangent is: ",$ZTAN(num)
   QUIT
The following example compares the results from InterSystems IRIS fractional numbers ($DECIMAL numbers) and $DOUBLE numbers. In both cases, the tangent of 0 is exactly 0, but the tangent of pi is a negative fractional number (not exactly 0):
  WRITE !,"the tangent is: ",$ZTAN(0.0)
  WRITE !,"the tangent is: ",$ZTAN($DOUBLE(0.0))
  WRITE !,"the tangent is: ",$ZTAN($ZPI)
  WRITE !,"the tangent is: ",$ZTAN($DOUBLE($ZPI))
  WRITE !,"the tangent is: ",$ZTAN(1.0)
  WRITE !,"the tangent is: ",$ZTAN($DOUBLE(1.0))
See Also