Skip to main content

$ZSIN (ObjectScript)

Returns the trigonometric sine of the specified angle value.

Synopsis

$ZSIN(n)

Argument

Argument Description
n Angle in radians ranging from Pi to 2 Pi (inclusive). Other supplied numeric values are converted to a value within this range.

Description

$ZSIN returns the trigonometric sine of n. The result is a signed decimal number ranging from 1 to -1 (see note). $ZSIN(0) returns 0. $ZSIN($ZPI/2) returns 1.

Note:

$ZSIN (like all trigonometric functions) calculates its values based on pi rounded to the number of available decimal digits. Therefore, the value returned by $ZSIN($ZPI) is .000000000000000000462644 and $ZSIN($ZPI*2) is –.00000000000000000092529. For this reason you should not perform limit tests comparing these returned values to 0.

Argument

n

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; InterSystems IRIS resolve these values to the corresponding multiple of Pi. For example, 3 Pi is equivalent to Pi, and negative Pi is equivalent to Pi.

A non-numeric string is evaluated as 0. For evaluation of mixed numeric strings and non-numeric strings, refer to Strings As Numbers.

Examples

The following example permits you to compute the sine of a number:

   READ "Input a number: ",num
   IF $ZABS(num)>(2*$ZPI) { WRITE !,"number is a larger than 2 pi" }
   ELSE { 
         WRITE !,"the sine is: ",$ZSIN(num)
        }
   QUIT

The following example compares the results from InterSystems IRIS fractional numbers ($DECIMAL numbers) and $DOUBLE numbers. In both cases, the sine of pi is a fractional number (not 0), but the sine of pi/2 is set to exactly 1:

  WRITE !,"the sine is: ",$ZSIN($ZPI)
  WRITE !,"the sine is: ",$ZSIN($DOUBLE($ZPI))
  WRITE !,"the sine is: ",$ZSIN($ZPI/2)
  WRITE !,"the sine is: ",$ZSIN($DOUBLE($ZPI)/2)

In the following example, all $ZSIN functions return zero (0):

  WRITE !,"the sine is: ",$ZSIN(0.0)
  WRITE !,"the sine is: ",$ZSIN(-0.0)
  WRITE !,"the sine is: ",$ZSIN($DECIMAL(0.0))
  WRITE !,"the sine is: ",$ZSIN($DOUBLE(0.0))
  WRITE !,"the sine is: ",$ZSIN($DECIMAL(-0.0))
  WRITE !,"the sine is: ",$ZSIN($DOUBLE(-0.0))
  WRITE !,"the sine is: ",$ZSIN(-$DECIMAL(0.0))
  WRITE !,"the sine is: ",$ZSIN(-$DOUBLE(0.0))

This is true on all platforms, including AIX.

See Also

Purpose of this instance: Draft documentation
DocReleaseID: HealthConnect2025.1
Content loaded from:
/staging/learning/iris-doc/2025.1.x/doc/cache/en-us/src/
/staging/learning/iris-doc/2025.1.x/doc/ensemble/en-us/src/
/staging/learning/iris-doc/2025.1.x/doc/healthconnect/en-us/src/
/staging/learning/iris-doc/2025.1.x/doc/healthcommon/en-us/src/
/staging/learning/iris-doc/2025.1.x/doc/security/en-us/src/
Excluded items: AADAN, ABIT, ACLOUD, AFL_adonet, AFL_ecp, AFL_icm, AFL_jdbc, AFL_netxep, AFL_sharding, AFL_xep, APMML, APOWER, ARGATEWAY, AWEBSOCKETS, AWSGI, BJAVA, BJAVNAT, BJAVPER, BJAVXEP, BJSNAT, BNET, BNETNAT, BNETODBC, BNETXEP, BPYNAT, BSPK, BTPI, BXCI, GAUTOML, GCONV, GCSP, GICM, GIKNOW, GIML, GISQ, GISR, GSCF, GSQLSRCH, GTSQ, GUIMA, PAGE_activex, PAGE_administration, PAGE_apimgr, PAGE_appdev_ides, PAGE_bi, PAGE_cachedirect, PAGE_data_migration, PAGE_data_science, PAGE_deployment, PAGE_deployment_configuration, PAGE_deployment_containers, PAGE_deployment_icm, PAGE_deployment_iko, PAGE_deployment_install, PAGE_dotnet, PAGE_dotnet_native, PAGE_dsvr, PAGE_embedded_language_development, PAGE_epython, PAGE_external_language_development, PAGE_interop, PAGE_interop_lifecycle, PAGE_interop_vdoc, PAGE_interoperability, PAGE_java, PAGE_java_jdbc, PAGE_java_native, PAGE_machine_learning, PAGE_monitoring, PAGE_multimodel, PAGE_multimodel_multidimensional, PAGE_multimodel_object, PAGE_multivalue, PAGE_native, PAGE_nodejs_native, PAGE_objectscript, PAGE_objectscript_ides, PAGE_odbc, PAGE_platform_arch_design, PAGE_pygate, PAGE_python, PAGE_python_native, PAGE_reports, PAGE_scalability, PAGE_security_authentication, PAGE_security_authorization, PAGE_studio, PAGE_zen, PAGE_zenmojo, PAGE_zenreports
FeedbackOpens in a new tab