Ansicht
Dokumentation

ABENFLOATING_POINT_FUNCTIONS - FLOATING POINT FUNCTIONS

ABENFLOATING_POINT_FUNCTIONS - FLOATING POINT FUNCTIONS

Fill RESBD Structure from EBP Component Structure   Addresses (Business Address Services)  
This documentation is copyright by SAP AG.
SAP E-Book

- acos, sin, tanh, exp, log, sqrt, ...

... num_func( arg ) ...

Effect

Built-in floating point function for which a floating point number is expected as an unnamed argument. Floating point functions are overloaded so that the return value can have the type decfloat34 or f. Decimal floating point numbers can only be used as arguments of exp, log, log10, and sqrt. The argument of a floating point function must be a single data object outside an arithmetic expression and can be an arithmetic expression itself within an arithmetic expression.

The following table shows the floating point function and how it works.

Function num_func Meaning Definition Range
acos arccosine [-1,1], no decfloat34
asin arcsine [-1,1], no decfloat34
atan arctangent -, no decfloat34
cos cosine -, no decfloat34
sin sine -, no decfloat34
tan tangent -, no decfloat34
cosh hyperbolic cosine -, no decfloat34
sinh hyperbolic sine -, no decfloat34
tanh hyperbolic tangent -, no decfloat34
exp Exponential function for base e [-709, 709] for type f and [-14144, 14149] for type decfloat34
log Natural logarithm > 0
log10 Logarithm to base 10 > 0
sqrt Square root >= 0

Functions for which "no decfloat34" is specified cannot currently have the calculation type decfloat34. If one of these functions is specified in an expression with this calculation type, a syntax error occurs or the exception CX_SY_UNSUPPORTED_FUNCTION is raised.

The following applies to the floating point arithmetic in which a floating point function is calculated, and to the data type of the return value:

  • If the argument has the type decfloat16 or decfloat34, a floating point function is calculated in decimal floating point arithmetic and the return value has the type decfloat34.
  • If a floating point function is used in an arithmetic expression whose calculation type is decfloat34, or that contains a numeric expression of type decfloat34 as an argument, it also calculates a return value with the type decfloat34 and the argument is first converted to the data type decfloat34, if necessary.
  • In all other cases, floating point functions use binary floating point arithmetic to calculate a return value with type f and the argument is first converted to the data type f, if necessary.

Functions with a definition range require the value of arg to be within the specified limits. Arguments within the definition ranges are guaranteed to be error-free for the exponential function exp, since the results are then within the value ranges for binary or decimal floating point numbers in accordance with IEEE-754. For arguments less than -709, the result for binary floating point numbers is a subnormal number, 0, depending on the platform, or a catchable exception of the class CX_SY_ARITHMETIC_OVERFLOW is raised from a specific value.

The trigonometric functions sin, cos, and tan are defined for any arguments, but the results become imprecise if the argument is greater than approximately 100,000,000.

Notes

  • The atan function is undefined for odd multiples of pi/2, but the definition range of atan is not restricted since an argument of this function can never contain the precise value of pi/2.

Example

The results in the internal table should all have the value 1 or be very close to this value.

Exceptions

Catchable Exceptions

CX_SY_ARG_OUT_OF_DOMAIN

  • Cause: Invalid call of acos
    Runtime Error: COMPUTE_ACOS_DOMAIN
  • Cause: Invalid call of asin
    Runtime Error: COMPUTE_ASIN_DOMAIN
  • Cause: Invalid call of cos
    Runtime Error: COMPUTE_COS_DOMAIN
  • Cause: Invalid call of log10
    Runtime Error: COMPUTE_LOG10_ERROR
  • Cause: Invalid call of log
    Runtime Error: COMPUTE_LOG_ERROR
  • Cause: Invalid call of sin
    Runtime Error: COMPUTE_SIN_DOMAIN
  • Cause: Invalid call of sqrt
    Runtime Error: COMPUTE_SQRT_DOMAIN
  • Cause: Invalid call of tan
    Runtime Error: COMPUTE_TAN_DOMAIN





General Data in Customer Master   Addresses (Business Address Services)  
This documentation is copyright by SAP AG.

Length: 9334 Date: 20240419 Time: 221837     sap01-206 ( 110 ms )