CRE Programmer's Guide

Common Run-Time Environment (CRE) Programmer’s Guide528146-004
7-1
7 Math Functions
This section describes the interfaces to the math functions. It describes:
Arithmetic Overflow Handling on page 7-1
Standard Math Functions on page 7-1
Sixty-Four-Bit Logical Operations (Bit Manipulation Functions) on page 7-23
Remainder on page 7-25
Decimal Conversion Functions on page 7-25
Each function described in this section begins with the prefix RTL_ or CRE_. Refer to
Using Standard Functions
on page 2-56 for more information.
The pTAL RTL functions, data, and data structure declarations are in the RTLRDECS
file.
Arithmetic Overflow Handling
In the TNS CRE environment, functions that can cause an arithmetic overflow specify
that a fault might occur, rather than specifying that a trap might occur. A TNS CRE or
RTL function that can cause an arithmetic overflow disables overflow traps while it
executes and tests explicitly for arithmetic overflow after each instruction that can
cause it. Prior to returning, the function enables the arithmetic overflow bit in the
environment register image of the most recent stack marker. If traps were enabled
when your program called the function, your program will trap immediately upon return
from the function. If traps were disabled when your program called the function, your
program will not trap. You might be able to test explicitly for arithmetic overflow upon
return from the function. Refer to the language manual for your routine that calls the
function for more information on detecting arithmetic overflow.
The native CRE environment provides only non-trapping variants for functions that can
cause an arithmetic trap. Non-trapping variants dynamically detect an arithmetic fault,
set
errno, and return an appropriate value.
Since the native CRE architecture does not have a saved environment register, you
must evaluate
errno upon return from the function. Refer to the language manual for
your routine that calls the function for more information on detecting arithmetic
overflow.
Standard Math Functions
This subsection describes the standard math functions. Table 7-1 on page 7-2
summarizes the standard math functions.