MTH$ - MATH Routines
Overview
VX/MTH$ is a call-compatible re-implementation of the OpenVMS MTH$ mathematics run-time library for x86 and ARM Linux. It provides the MTH$ entry points that DEC and VSI applications call for trigonometry, logarithms, exponentials, square roots, min/max selection, sign handling, and floating-point conversions, so migrated programs link and run while preserving numerical behaviour. It is the runtime the compiled or translated object links against, not the compiler and not a source translator.
Every routine is a thin wrapper over the host platform's IEEE-754 math implementation, exposed under the original VMS call names so a program written against VAX or Alpha MTH$ compiles and links unchanged. VX/MTH$ ships inside VX/RT alongside the other OpenVMS run-time libraries such as LIB$, OTS$, STR$, and FOR$, giving OpenVMS applications that depend on MTH$ routines full mathematical functionality on Linux without source changes.
<!-- Webflow embed (min). Source: mth-page-technical/mth-tech-body-embed-dark.html → python3 website/embeds/minify_webflow_embed.py … -->
<div class="s7-tech-embed" data-vxmthd-body-embed="1" data-technical-mega-embed="1" lang="en"><h2 id="architecture">Architecture and linkage</h2><p>
VX/MTH$ is a link-time library, not a running service. Each routine is compiled from a
thin C or C++ body over the host platform's <code><math.h></code> functions and archived
into the VX runtime static library, <code>libvxrt.a</code>. A migrated application links that
archive and calls the <code>MTH$</code> entry points directly, exactly as it linked the
OpenVMS mathematics run-time library before. There is no MTH$ server process, no daemon, no
initialisation call, and no per-call allocation.
</p><div class="table-wrapper"><table><thead><tr><th>Property</th><th>VX/MTH$</th></tr></thead><tbody><tr><td>Delivery</td><td>Object modules archived into <code>libvxrt.a</code>, linked into the application.</td></tr><tr><td>Implementation language</td><td>C and C++ with <code>extern "C"</code> bodies over IEEE-754 <code><math.h></code>.</td></tr><tr><td>Public entry points</td><td>The full OpenVMS <code>MTH$</code> callable API surface (see the routine table below).</td></tr><tr><td>Calling model</td><td>Direct in-process function calls; no runtime server, no IPC.</td></tr><tr><td>Target platforms</td><td>x86 and ARM Linux, through the VX/RT runtime.</td></tr><tr><td>Prototypes</td><td>Shared VX headers (routine declarations, condition symbols, call-name aliases).</td></tr></tbody></table></div><h6>Component layers</h6><p>
MTH$ has no processes to administer. Its parts are the numeric routine bodies, the call-name
aliasing layer that wires the VMS and Fortran call names to each body, a small set of shared
helpers, and the condition and signal layer that reports domain errors.
</p><div class="table-wrapper"><table><thead><tr><th>Layer</th><th>Role</th></tr></thead><tbody><tr><td>Routine bodies</td><td>One C or C++ body per routine, each a guarded call into the host math library.</td></tr><tr><td>Alias layer</td><td>Emits the four VMS and Fortran call names that resolve to each routine's canonical symbol.</td></tr><tr><td>Radian and degree helpers</td><td>Shared conversion helpers used by the trigonometry-in-degrees families.</td></tr><tr><td>Variadic min and max workhorses</td><td>Scan an array of operands and return the extremum for the <code>MAX</code> and <code>MIN</code> families.</td></tr><tr><td>Condition and signal layer</td><td>Raises VMS-style conditions for domain errors through the LIB$ signal path.</td></tr></tbody></table></div><h6>Link model</h6><style>.s7-tech-embed .process-flow {margin: 1.5rem 0;padding: 16px;border: 1px solid var(--s7t-border);border-radius: 10px;background: rgba(255, 255, 255, 0.01);}.s7-tech-embed .process-endpoint {display: grid;grid-template-columns: 72px minmax(0, 1fr);gap: 14px;align-items: center;padding: 14px 16px;border-radius: 8px;background: var(--s7t-surface);color: var(--s7t-text);}.s7-tech-embed .process-output {border: 1px solid var(--s7t-note-bd);background: var(--s7t-note-bg);}.s7-tech-embed .process-runtime {margin-top: 10px;}.s7-tech-embed .process-label,.s7-tech-embed .process-number {font-family: var(--s7t-mono);color: var(--s7t-accent);font-size: 0.76em;font-weight: 700;letter-spacing: 0.08em;text-transform: uppercase;}.s7-tech-embed .process-endpoint div,.s7-tech-embed .process-stage {min-width: 0;}.s7-tech-embed .process-endpoint strong,.s7-tech-embed .process-endpoint span:last-child,.s7-tech-embed .process-stage strong,.s7-tech-embed .process-stage span:last-child {display: block;}.s7-tech-embed .process-endpoint strong,.s7-tech-embed .process-stage strong {margin-bottom: 4px;color: var(--s7t-text);}.s7-tech-embed .process-endpoint span:last-child,.s7-tech-embed .process-stage span:last-child {color: var(--s7t-muted);font-size: 0.9em;line-height: 1.45;}.s7-tech-embed .process-stages {display: grid;grid-template-columns: repeat(3, minmax(0, 1fr));gap: 10px;margin: 10px 0;}.s7-tech-embed .process-stage {padding: 15px;border-top: 3px solid var(--s7t-accent);border-radius: 6px;background: var(--s7t-surface2);color: var(--s7t-text);}.s7-tech-embed .process-stage .process-number {margin-bottom: 10px;}@media (max-width: 800px) {.s7-tech-embed .process-stages {grid-template-columns: 1fr;}.s7-tech-embed .process-endpoint {grid-template-columns: 1fr;gap: 5px;}}</style><div class="process-flow" aria-label="VX/MTH link model and routine families"><div class="process-endpoint"><span class="process-label">Caller</span><div><strong>Application object code</strong><span>Calls MTH$DSQRT, MTH$DEXP, MTH$SIND, MTH$DMAX1, and related routines.</span></div></div><div class="process-endpoint process-runtime"><span class="process-label">Archive</span><div><strong>MTH$ object modules in libvxrt.a</strong><span>The linker resolves each MTH$ call to its numeric service-family implementation.</span></div></div><div class="process-stages"><div class="process-stage"><span class="process-number">01</span><strong>Trigonometry</strong><span>Radian and degree-based trigonometric functions.</span></div><div class="process-stage"><span class="process-number">02</span><strong>Logarithms</strong><span>Natural and common logarithm families.</span></div><div class="process-stage"><span class="process-number">03</span><strong>Exponentials</strong><span>Exponential and power-related functions.</span></div><div class="process-stage"><span class="process-number">04</span><strong>Square roots</strong><span>Guarded square-root routines across supported types.</span></div><div class="process-stage"><span class="process-number">05</span><strong>Min and max</strong><span>Variadic extrema routines for numeric families.</span></div><div class="process-stage"><span class="process-number">06</span><strong>Bitwise</strong><span>Numeric bit manipulation routines.</span></div><div class="process-stage"><span class="process-number">07</span><strong>Conversion</strong><span>Cross-type numeric conversion routines.</span></div></div><div class="process-endpoint process-output"><span class="process-label">Target</span><div><strong>VX/RT runtime</strong><span>x86 or ARM Linux.</span></div></div></div><div class="callout"><strong>No server to administer.</strong> MTH$ services resolve at link time and execute
in-process. Deploying VX/MTH$ means shipping the linked binary, not standing up a service or
configuring a daemon.
</div><h2 id="conventions">Naming, linkage and calling conventions</h2><p>
Every routine is exposed under four equivalent call names, so existing object references and
source in any supported language resolve without change. Each source body defines one
canonical C symbol of the form <code>MTH_D_<NAME></code>; an alias macro then wires the
uppercase VMS dollar-sign name, its lowercase spelling, and both trailing-underscore forms to
that single body.
</p><div class="table-wrapper"><table><thead><tr><th>Name form</th><th>Example</th><th>Used by</th></tr></thead><tbody><tr><td>VMS dollar-sign name</td><td><code>MTH$DSQRT</code></td><td>Recompiled OpenVMS object code and assembler references.</td></tr><tr><td>Lowercase alias</td><td><code>mth$dsqrt</code></td><td>Case-sensitive toolchains and mixed-case source.</td></tr><tr><td>Trailing-underscore forms</td><td><code>mth$dsqrt_</code>, <code>MTH$DSQRT_</code></td><td>The gfortran and g77 Fortran ABI entry points.</td></tr><tr><td>Canonical C symbol</td><td><code>MTH_D_DSQRT</code></td><td>The one body all four aliases resolve to.</td></tr></tbody></table></div><p>
Because MTH$ arguments are scalars passed by reference, the C and Fortran-77 call paths are
identical: a Fortran <code>Y = DSQRT(X)</code> resolves to <code>dsqrt_</code>, which is just
another alias of the same routine, with no separate Fortran thunk needed.
</p><h6>Argument-passing rules</h6><div class="table-wrapper"><table><thead><tr><th>Rule</th><th>Detail</th></tr></thead><tbody><tr><td>Arguments by reference</td><td>All arguments are passed as pointer-to-value, following the VAX convention.</td></tr><tr><td>Scalar result by value</td><td>Most routines return their numeric result directly by value.</td></tr><tr><td>H family output pointer</td><td>The <code>H</code> (h-float) family instead takes a leading output pointer and returns <code>void</code>.</td></tr><tr><td>Variadic min and max</td><td>The <code>MAX</code> and <code>MIN</code> families take a leading count argument equal to the operand count minus one.</td></tr><tr><td>IEEE double internally</td><td>All computation is performed in IEEE <code>double</code>; the historical VAX float formats collapse to one representation.</td></tr></tbody></table></div><div class="callout"><strong>One representation, many entry points.</strong> The <code>D</code>, <code>G</code>,
and <code>H</code> entry-point families exist for source compatibility. They all delegate to
the same IEEE <code>double</code> arithmetic, so callers get consistent results across the
precision variants they originally used on VAX and Alpha.
</div><h6>Type-prefix legend</h6><p>The first letter or letters of a routine name encode the operand and result type:</p><div class="table-wrapper"><table><thead><tr><th>Prefix</th><th>Type</th></tr></thead><tbody><tr><td>none or <code>A</code></td><td>f-float, single-precision <code>float</code>.</td></tr><tr><td><code>D</code></td><td>d-float, double-precision <code>double</code>.</td></tr><tr><td><code>G</code></td><td>g-float, mapped to <code>double</code> (same body as the D form).</td></tr><tr><td><code>H</code></td><td>h-float, result returned through a leading output pointer.</td></tr><tr><td><code>I</code> or <code>J</code></td><td>16-bit and 32-bit signed integer.</td></tr><tr><td><code>II</code> or <code>JI</code></td><td>16-bit and 32-bit integer for the bitwise and integer families.</td></tr></tbody></table></div><h6>A routine body</h6><p>
Routine bodies are plain <code>extern "C"</code> functions that dereference their arguments,
guard the domain where required, and call the host math library. Double square root, which
signals on a negative operand, is representative:
</p>
<pre><span class="kw">extern "C"</span> <span class="kw">double</span> MTH_D_DSQRT(<span class="kw">double</span> *d) {
<span class="kw">if</span> (*d < 0) LIB_D_SIGNAL(MTH_s_SQUROONEG); <span class="cmt">/* sqrt of negative */</span>
<span class="kw">return</span> sqrt(*d);
}
__AliasF(MTH_D_DSQRT, MTH$DSQRT, mth$dsqrt); <span class="cmt">/* wires all four call names */</span></pre>
<h6>Calling a routine</h6><p>
A migrated program links against <code>libvxrt.a</code> and calls the <code>MTH$</code> entry
points directly, passing arguments by reference. The by-value return, the h-float output
pointer, and the leading count on the variadic routines all appear below:
</p>
<pre><span class="cmt">/* by-value return, by-reference argument (VAX convention) */</span>
<span class="kw">double</span> x = 2.0, root;
root = MTH$DSQRT(&x); <span class="cmt">/* root = sqrt(2.0) */</span>
<span class="cmt">/* interest factor for a statement line: e ^ rate */</span>
<span class="kw">double</span> rate = 0.045, factor;
factor = MTH$DEXP(&rate);
<span class="cmt">/* h-float family: result via a leading output pointer, returns void */</span>
<span class="kw">double</span> h_in = 2.0, h_out;
MTH$HABS(&h_out, &h_in); <span class="cmt">/* h_out = 2.0 */</span>
<span class="cmt">/* variadic max: leading n = (operand count - 1), reads d plus n more */</span>
<span class="kw">double</span> a = 1.0, b = 9.0, c = 4.0, largest;
largest = MTH$DMAX1(2, &a, &b, &c); <span class="cmt">/* n = 2, three operands, result 9.0 */</span></pre>
<h2 id="routine-families">Routine families</h2><p>
The MTH$ library groups its routines by mathematical function. Within each group the
per-prefix variants (single-precision, double-precision, g-float and h-float, and the integer
forms) share one underlying body. The table names each group and a representative sample; the
complete list follows in the next section.
</p><div class="table-wrapper"><table><thead><tr><th>Group</th><th>What it covers</th><th>Representative routines</th></tr></thead><tbody><tr><td>Absolute value and sign</td><td>Magnitude, sign transfer, and sign extraction.</td><td><code>MTH$ABS</code>, <code>MTH$DABS</code>, <code>MTH$SIGN</code>, <code>MTH$DSIGN</code>, <code>MTH$SGN</code></td></tr><tr><td>Exponential and logarithm</td><td>Exponentials and natural, base-10, and base-2 logarithms.</td><td><code>MTH$EXP</code>, <code>MTH$DEXP</code>, <code>MTH$ALOG</code>, <code>MTH$DLOG10</code>, <code>MTH$DLOG2</code></td></tr><tr><td>Square root</td><td>Square root across the precision variants, guarded for negative operands.</td><td><code>MTH$SQRT</code>, <code>MTH$DSQRT</code>, <code>MTH$GSQRT</code>, <code>MTH$HSQRT</code></td></tr><tr><td>Trigonometry in radians</td><td>Sine, cosine, and tangent and their combined and inverse forms.</td><td><code>MTH$SIN</code>, <code>MTH$COS</code>, <code>MTH$TAN</code>, <code>MTH$DSIN</code>, <code>MTH$SINCOS</code></td></tr><tr><td>Trigonometry in degrees</td><td>Degree variants of the trigonometric and inverse trigonometric routines.</td><td><code>MTH$SIND</code>, <code>MTH$COSD</code>, <code>MTH$TAND</code>, <code>MTH$ASIND</code>, <code>MTH$ATAND</code></td></tr><tr><td>Inverse trigonometry</td><td>Arc sine, arc cosine, and arc tangent, including the two-argument arc tangent.</td><td><code>MTH$ASIN</code>, <code>MTH$ACOS</code>, <code>MTH$ATAN</code>, <code>MTH$ATAN2</code>, <code>MTH$DATAN2</code></td></tr><tr><td>Hyperbolic</td><td>Hyperbolic sine, cosine, and tangent across the precision variants.</td><td><code>MTH$SINH</code>, <code>MTH$COSH</code>, <code>MTH$TANH</code>, <code>MTH$DSINH</code>, <code>MTH$DTANH</code></td></tr><tr><td>Rounding and truncation</td><td>Truncate toward zero, round to nearest, floor, and positive difference.</td><td><code>MTH$AINT</code>, <code>MTH$DINT</code>, <code>MTH$ANINT</code>, <code>MTH$FLOOR</code>, <code>MTH$DIM</code></td></tr><tr><td>Modulus and product</td><td>Floating and integer modulus and double-precision product.</td><td><code>MTH$AMOD</code>, <code>MTH$DMOD</code>, <code>MTH$DPROD</code>, <code>MTH$GPROD</code></td></tr><tr><td>Minimum and maximum</td><td>Variadic selection of the least or greatest of a list of operands.</td><td><code>MTH$AMAX1</code>, <code>MTH$DMAX1</code>, <code>MTH$IMIN0</code>, <code>MTH$UMAX</code>, <code>MTH$UMIN</code></td></tr><tr><td>Precision and type conversion</td><td>Single to double casts, double to single, and integer to floating conversions.</td><td><code>MTH$DBLE</code>, <code>MTH$SNGL</code>, <code>MTH$FLOATI</code>, <code>MTH$DFLOTJ</code>, <code>MTH$CVT_G_D</code></td></tr><tr><td>Float to integer conversion</td><td>Truncating and rounding conversions from floating values to 16-bit and 32-bit integers.</td><td><code>MTH$IIFIX</code>, <code>MTH$JINT</code>, <code>MTH$ININT</code>, <code>MTH$JNINT</code></td></tr><tr><td>Integer and bitwise</td><td>Integer absolute, sign, and difference, plus bitwise AND, OR, XOR, NOT, and shift.</td><td><code>MTH$IIABS</code>, <code>MTH$IIAND</code>, <code>MTH$IIOR</code>, <code>MTH$IIEOR</code>, <code>MTH$IISHFT</code></td></tr><tr><td>Random</td><td>Pseudo-random number generation.</td><td><code>MTH$RANDOM</code></td></tr></tbody></table></div><h2 id="callable-routines">VX/MTH$ callable routines</h2><p>
The full set of callable MTH$ routines, spanning trigonometry, logarithms, exponentials,
square roots, minimum and maximum selection, sign and rounding functions, integer and bitwise
operations, and floating-point conversions. Each is available under its VMS dollar-sign name
as well as the portable C and Fortran-callable aliases described above.
</p><div class="table-wrapper"><table><thead><tr><th>MTH$ API</th><th>Function</th></tr></thead><tbody><tr><td><code>MTH$ABS</code></td><td>Absolute value of a number</td></tr><tr><td><code>MTH$ACOS</code></td><td>Arc cosine function</td></tr><tr><td><code>MTH$ACOSD</code></td><td>Arc cosine in degrees</td></tr><tr><td><code>MTH$AIMAX0</code></td><td>Integer maximum of values</td></tr><tr><td><code>MTH$AIMIN0</code></td><td>Integer minimum of values</td></tr><tr><td><code>MTH$AINT</code></td><td>Truncate to integer</td></tr><tr><td><code>MTH$AJMAX0</code></td><td>Integer max (adjustable)</td></tr><tr><td><code>MTH$AJMIN0</code></td><td>Integer min (adjustable)</td></tr><tr><td><code>MTH$ALOG</code></td><td>Natural logarithm</td></tr><tr><td><code>MTH$ALOG10</code></td><td>Base-10 logarithm</td></tr><tr><td><code>MTH$ALOG2</code></td><td>Base-2 logarithm</td></tr><tr><td><code>MTH$AMAX1</code></td><td>Maximum of floating values</td></tr><tr><td><code>MTH$AMIN1</code></td><td>Minimum of floating values</td></tr><tr><td><code>MTH$AMOD</code></td><td>Modulus function</td></tr><tr><td><code>MTH$ANINT</code></td><td>Nearest integer function</td></tr><tr><td><code>MTH$ASIN</code></td><td>Arc sine function</td></tr><tr><td><code>MTH$ASIND</code></td><td>Arc sine in degrees</td></tr><tr><td><code>MTH$ATAN</code></td><td>Arc tangent function</td></tr><tr><td><code>MTH$ATAN2</code></td><td>Arc tangent of two args</td></tr><tr><td><code>MTH$ATAND</code></td><td>Arc tangent in degrees</td></tr><tr><td><code>MTH$ATAND2</code></td><td>Arc tangent of two args, in degrees</td></tr><tr><td><code>MTH$ATANH</code></td><td>Inverse hyperbolic tangent</td></tr><tr><td><code>MTH$COS</code></td><td>Cosine function</td></tr><tr><td><code>MTH$COSD</code></td><td>Cosine in degrees</td></tr><tr><td><code>MTH$COSH</code></td><td>Hyperbolic cosine</td></tr><tr><td><code>MTH$CVT_D_G</code></td><td>Convert double to G format</td></tr><tr><td><code>MTH$CVT_G_D</code></td><td>Convert G format to double</td></tr><tr><td><code>MTH$DABS</code></td><td>Double precision absolute</td></tr><tr><td><code>MTH$DACOS</code></td><td>Double arc cosine</td></tr><tr><td><code>MTH$DACOSD</code></td><td>Double arc cosine in degrees</td></tr><tr><td><code>MTH$DASIN</code></td><td>Double arc sine</td></tr><tr><td><code>MTH$DASIND</code></td><td>Double arc sine in degrees</td></tr><tr><td><code>MTH$DATAN</code></td><td>Double arc tangent</td></tr><tr><td><code>MTH$DATAN2</code></td><td>Double arc tangent (2 args)</td></tr><tr><td><code>MTH$DATAND</code></td><td>Double arc tangent in degrees</td></tr><tr><td><code>MTH$DATAND2</code></td><td>Double atan2 in degrees</td></tr><tr><td><code>MTH$DATANH</code></td><td>Double inverse hyperbolic tangent</td></tr><tr><td><code>MTH$DBLE</code></td><td>Convert integer to double</td></tr><tr><td><code>MTH$DCOS</code></td><td>Double cosine</td></tr><tr><td><code>MTH$DCOSD</code></td><td>Computes the cosine of an angle in degrees</td></tr><tr><td><code>MTH$DCOSH</code></td><td>Double hyperbolic cosine</td></tr><tr><td><code>MTH$DDIM</code></td><td>Double positive difference</td></tr><tr><td><code>MTH$DEXP</code></td><td>Double exponential function</td></tr><tr><td><code>MTH$DFLOOR</code></td><td>Floor function for double</td></tr><tr><td><code>MTH$DFLOTI</code></td><td>Convert integer to float</td></tr><tr><td><code>MTH$DFLOTJ</code></td><td>Convert integer to float</td></tr><tr><td><code>MTH$DIM</code></td><td>Positive difference function</td></tr><tr><td><code>MTH$DINT</code></td><td>Double integer truncation</td></tr><tr><td><code>MTH$DLOG</code></td><td>Double natural logarithm</td></tr><tr><td><code>MTH$DLOG10</code></td><td>Double base-10 logarithm</td></tr><tr><td><code>MTH$DLOG2</code></td><td>Double base-2 logarithm</td></tr><tr><td><code>MTH$DMAX1</code></td><td>Double maximum value</td></tr><tr><td><code>MTH$DMIN1</code></td><td>Double minimum value</td></tr><tr><td><code>MTH$DMOD</code></td><td>Double modulus function</td></tr><tr><td><code>MTH$DNINT</code></td><td>Nearest integer (double)</td></tr><tr><td><code>MTH$DPROD</code></td><td>Double precision product</td></tr><tr><td><code>MTH$DSIGN</code></td><td>Double sign function</td></tr><tr><td><code>MTH$DSIN</code></td><td>Double sine function</td></tr><tr><td><code>MTH$DSINCOS</code></td><td>Double sine and cosine</td></tr><tr><td><code>MTH$DSINCOSD</code></td><td>Double sin/cos in degrees</td></tr><tr><td><code>MTH$DSIND</code></td><td>Double sine in degrees</td></tr><tr><td><code>MTH$DSINH</code></td><td>Double hyperbolic sine</td></tr><tr><td><code>MTH$DSQRT</code></td><td>Double square root</td></tr><tr><td><code>MTH$DTAN</code></td><td>Double tangent function</td></tr><tr><td><code>MTH$DTAND</code></td><td>Double tangent in degrees</td></tr><tr><td><code>MTH$DTANH</code></td><td>Double hyperbolic tangent</td></tr><tr><td><code>MTH$EXP</code></td><td>Exponential function</td></tr><tr><td><code>MTH$FLOATI</code></td><td>Convert integer to float</td></tr><tr><td><code>MTH$FLOATJ</code></td><td>Convert integer to float</td></tr><tr><td><code>MTH$FLOOR</code></td><td>Floor function</td></tr><tr><td><code>MTH$GABS</code></td><td>General absolute value</td></tr><tr><td><code>MTH$GACOS</code></td><td>General arc cosine</td></tr><tr><td><code>MTH$GACOSD</code></td><td>General arc cosine in degrees</td></tr><tr><td><code>MTH$GASIN</code></td><td>General arc sine</td></tr><tr><td><code>MTH$GASIND</code></td><td>General arc sine in degrees</td></tr><tr><td><code>MTH$GATAN</code></td><td>General arc tangent</td></tr><tr><td><code>MTH$GATAN2</code></td><td>General arc tangent (2 args)</td></tr><tr><td><code>MTH$GATAND</code></td><td>General arc tangent in degrees</td></tr><tr><td><code>MTH$GATAND2</code></td><td>General atan2 in degrees</td></tr><tr><td><code>MTH$GATANH</code></td><td>Computes the inverse hyperbolic tangent</td></tr><tr><td><code>MTH$GCOS</code></td><td>General cosine function</td></tr><tr><td><code>MTH$GCOSD</code></td><td>General cosine in degrees</td></tr><tr><td><code>MTH$GCOSH</code></td><td>General hyperbolic cosine</td></tr><tr><td><code>MTH$GDBLE</code></td><td>General double precision</td></tr><tr><td><code>MTH$GDIM</code></td><td>General positive difference</td></tr><tr><td><code>MTH$GEXP</code></td><td>General exponential function</td></tr><tr><td><code>MTH$GFLOOR</code></td><td>General floor function</td></tr><tr><td><code>MTH$GFLOTI</code></td><td>General integer to float</td></tr><tr><td><code>MTH$GFLOTJ</code></td><td>General integer to float</td></tr><tr><td><code>MTH$GINT</code></td><td>General integer truncation</td></tr><tr><td><code>MTH$GLOG</code></td><td>General natural logarithm</td></tr><tr><td><code>MTH$GLOG10</code></td><td>General base-10 logarithm</td></tr><tr><td><code>MTH$GLOG2</code></td><td>General base-2 logarithm</td></tr><tr><td><code>MTH$GMAX1</code></td><td>General maximum value</td></tr><tr><td><code>MTH$GMIN1</code></td><td>General minimum value</td></tr><tr><td><code>MTH$GMOD</code></td><td>General modulus function</td></tr><tr><td><code>MTH$GNINT</code></td><td>General nearest integer</td></tr><tr><td><code>MTH$GPROD</code></td><td>General precision product</td></tr><tr><td><code>MTH$GSIGN</code></td><td>General sign function</td></tr><tr><td><code>MTH$GSIN</code></td><td>General sine function</td></tr><tr><td><code>MTH$GSINCOS</code></td><td>General sine and cosine</td></tr><tr><td><code>MTH$GSINCOSD</code></td><td>General sin/cos in degrees</td></tr><tr><td><code>MTH$GSIND</code></td><td>General sine in degrees</td></tr><tr><td><code>MTH$GSINH</code></td><td>General hyperbolic sine</td></tr><tr><td><code>MTH$GSQRT</code></td><td>General square root</td></tr><tr><td><code>MTH$GTAN</code></td><td>General tangent function</td></tr><tr><td><code>MTH$GTAND</code></td><td>General tangent in degrees</td></tr><tr><td><code>MTH$GTANH</code></td><td>General hyperbolic tangent</td></tr><tr><td><code>MTH$HABS</code></td><td>Hyperbolic absolute value</td></tr><tr><td><code>MTH$HACOS</code></td><td>Hyperbolic arc cosine</td></tr><tr><td><code>MTH$HACOSD</code></td><td>Hyperbolic arc cosine in degrees</td></tr><tr><td><code>MTH$HASIN</code></td><td>Hyperbolic arc sine</td></tr><tr><td><code>MTH$HASIND</code></td><td>Hyperbolic arc sine in degrees</td></tr><tr><td><code>MTH$HATAN</code></td><td>Hyperbolic arc tangent</td></tr><tr><td><code>MTH$HATAN2</code></td><td>Hyperbolic arc tangent (2 args)</td></tr><tr><td><code>MTH$HATAND</code></td><td>Hyperbolic arc tangent in degrees</td></tr><tr><td><code>MTH$HATAND2</code></td><td>Hyperbolic atan2 in degrees</td></tr><tr><td><code>MTH$HATANH</code></td><td>Inverse hyperbolic tangent</td></tr><tr><td><code>MTH$HCOS</code></td><td>Hyperbolic cosine function</td></tr><tr><td><code>MTH$HCOSD</code></td><td>Computes the hyperbolic cosine in degrees</td></tr><tr><td><code>MTH$HCOSH</code></td><td>Hyperbolic cosine</td></tr><tr><td><code>MTH$HDBLE</code></td><td>Hyperbolic double precision</td></tr><tr><td><code>MTH$HDIM</code></td><td>Hyperbolic positive difference</td></tr><tr><td><code>MTH$HEXP</code></td><td>Hyperbolic exponential function</td></tr><tr><td><code>MTH$HFLOOR</code></td><td>Hyperbolic floor function</td></tr><tr><td><code>MTH$HFLOTI</code></td><td>Hyperbolic integer to float</td></tr><tr><td><code>MTH$HFLOTJ</code></td><td>Hyperbolic integer to float</td></tr><tr><td><code>MTH$HINT</code></td><td>Hyperbolic integer truncation</td></tr><tr><td><code>MTH$HLOG</code></td><td>Hyperbolic natural logarithm</td></tr><tr><td><code>MTH$HLOG10</code></td><td>Hyperbolic base-10 logarithm</td></tr><tr><td><code>MTH$HLOG2</code></td><td>Hyperbolic base-2 logarithm</td></tr><tr><td><code>MTH$HMAX1</code></td><td>Hyperbolic maximum value</td></tr><tr><td><code>MTH$HMIN1</code></td><td>Hyperbolic minimum value</td></tr><tr><td><code>MTH$HMOD</code></td><td>Hyperbolic modulus function</td></tr><tr><td><code>MTH$HNINT</code></td><td>Hyperbolic nearest integer</td></tr><tr><td><code>MTH$HPROD</code></td><td>Hyperbolic precision product</td></tr><tr><td><code>MTH$HSIGN</code></td><td>Hyperbolic sign function</td></tr><tr><td><code>MTH$HSIN</code></td><td>Hyperbolic sine function</td></tr><tr><td><code>MTH$HSINCOS</code></td><td>Hyperbolic sine and cosine</td></tr><tr><td><code>MTH$HSINCOSD</code></td><td>Hyperbolic sin/cos in degrees</td></tr><tr><td><code>MTH$HSIND</code></td><td>Hyperbolic sine in degrees</td></tr><tr><td><code>MTH$HSINH</code></td><td>Hyperbolic sine</td></tr><tr><td><code>MTH$HSQRT</code></td><td>Hyperbolic square root</td></tr><tr><td><code>MTH$HTAN</code></td><td>Hyperbolic tangent function</td></tr><tr><td><code>MTH$HTAND</code></td><td>Hyperbolic tangent in degrees</td></tr><tr><td><code>MTH$HTANH</code></td><td>Hyperbolic tangent</td></tr><tr><td><code>MTH$IIABS</code></td><td>Integer absolute value</td></tr><tr><td><code>MTH$IIAND</code></td><td>Integer bitwise AND</td></tr><tr><td><code>MTH$IIDIM</code></td><td>Integer positive difference</td></tr><tr><td><code>MTH$IIDINT</code></td><td>Integer double precision</td></tr><tr><td><code>MTH$IIDNNT</code></td><td>Integer nearest value</td></tr><tr><td><code>MTH$IIEOR</code></td><td>Integer bitwise XOR</td></tr><tr><td><code>MTH$IIFIX</code></td><td>Integer fixed point conversion</td></tr><tr><td><code>MTH$IIGINT</code></td><td>Integer general integer</td></tr><tr><td><code>MTH$IIGNNT</code></td><td>Integer general nearest integer</td></tr><tr><td><code>MTH$IIHINT</code></td><td>Integer hyperbolic integer</td></tr><tr><td><code>MTH$IIHNNT</code></td><td>Integer hyperbolic nearest int</td></tr><tr><td><code>MTH$IINT</code></td><td>Integer conversion function</td></tr><tr><td><code>MTH$IIOR</code></td><td>Performs a bitwise OR operation</td></tr><tr><td><code>MTH$IISHFT</code></td><td>Integer bit shift function</td></tr><tr><td><code>MTH$IISIGN</code></td><td>Integer sign function</td></tr><tr><td><code>MTH$IMAX0</code></td><td>Integer maximum (0-based)</td></tr><tr><td><code>MTH$IMAX1</code></td><td>Integer maximum (1-based)</td></tr><tr><td><code>MTH$IMIN0</code></td><td>Integer minimum (0-based)</td></tr><tr><td><code>MTH$IMIN1</code></td><td>Integer minimum (1-based)</td></tr><tr><td><code>MTH$IMOD</code></td><td>Integer modulus function</td></tr><tr><td><code>MTH$ININT</code></td><td>Integer nearest integer</td></tr><tr><td><code>MTH$INOT</code></td><td>Integer bitwise NOT</td></tr><tr><td><code>MTH$JIABS</code></td><td>General integer absolute</td></tr><tr><td><code>MTH$JIAND</code></td><td>General integer bitwise AND</td></tr><tr><td><code>MTH$JIDIM</code></td><td>General integer positive difference</td></tr><tr><td><code>MTH$JIDINT</code></td><td>General integer double precision</td></tr><tr><td><code>MTH$JIDNNT</code></td><td>General integer nearest int</td></tr><tr><td><code>MTH$JIEOR</code></td><td>General integer bitwise XOR</td></tr><tr><td><code>MTH$JIFIX</code></td><td>General integer fixed point</td></tr><tr><td><code>MTH$JIGINT</code></td><td>General integer general int</td></tr><tr><td><code>MTH$JIGNNT</code></td><td>General integer nearest int</td></tr><tr><td><code>MTH$JIHINT</code></td><td>General integer hyperbolic int</td></tr><tr><td><code>MTH$JIHNNT</code></td><td>General int hyperbolic nearest</td></tr><tr><td><code>MTH$JINT</code></td><td>General integer conversion</td></tr><tr><td><code>MTH$JIOR</code></td><td>General integer bitwise OR</td></tr><tr><td><code>MTH$JISHFT</code></td><td>General integer bit shift</td></tr><tr><td><code>MTH$JISIGN</code></td><td>General integer sign function</td></tr><tr><td><code>MTH$JMAX0</code></td><td>General integer max (0-based)</td></tr><tr><td><code>MTH$JMAX1</code></td><td>General integer max (1-based)</td></tr><tr><td><code>MTH$JMIN0</code></td><td>General integer min (0-based)</td></tr><tr><td><code>MTH$JMIN1</code></td><td>General integer min (1-based)</td></tr><tr><td><code>MTH$JMOD</code></td><td>General integer modulus</td></tr><tr><td><code>MTH$JNINT</code></td><td>General integer nearest int</td></tr><tr><td><code>MTH$JNOT</code></td><td>General integer bitwise NOT</td></tr><tr><td><code>MTH$RANDOM</code></td><td>Generate a random number</td></tr><tr><td><code>MTH$SGN</code></td><td>Sign function</td></tr><tr><td><code>MTH$SGNEXT</code></td><td>Extended sign function</td></tr><tr><td><code>MTH$SIGN</code></td><td>Return sign of a number</td></tr><tr><td><code>MTH$SIN</code></td><td>Sine function</td></tr><tr><td><code>MTH$SINCOS</code></td><td>Sine and cosine functions</td></tr><tr><td><code>MTH$SINCOSD</code></td><td>Sine and cosine in degrees</td></tr><tr><td><code>MTH$SIND</code></td><td>Sine function in degrees</td></tr><tr><td><code>MTH$SINH</code></td><td>Computes the hyperbolic sine function</td></tr><tr><td><code>MTH$SNGL</code></td><td>Converts a double-precision floating point to single</td></tr><tr><td><code>MTH$SNGLG</code></td><td>Converts a generalized floating point to single</td></tr><tr><td><code>MTH$SQRT</code></td><td>Computes the square root of a number</td></tr><tr><td><code>MTH$TAN</code></td><td>Computes the tangent of an angle</td></tr><tr><td><code>MTH$TAND</code></td><td>Computes the tangent of an angle in degrees</td></tr><tr><td><code>MTH$TANH</code></td><td>Computes the hyperbolic tangent</td></tr><tr><td><code>MTH$UMAX</code></td><td>Returns the maximum of two unsigned numbers</td></tr><tr><td><code>MTH$UMIN</code></td><td>Returns the minimum of two unsigned numbers</td></tr></tbody></table></div><h2 id="status">Status and signal model</h2><p>
Math routines do not return status codes the way file or string routines do. A routine either
returns its numeric result directly, or, for the handful of status-bearing routines, returns
<code>SS$_NORMAL</code> (the value 1). Domain errors such as the square root of a negative
number or the logarithm of zero are reported as VMS-style conditions, raised through the LIB$
signal path so an established condition handler can catch them exactly as it did on OpenVMS.
</p><div class="table-wrapper"><table><thead><tr><th>Condition symbol</th><th>Value</th><th>Meaning</th><th>Raised by</th></tr></thead><tbody><tr><td><code>SS$_NORMAL</code></td><td><code>1</code></td><td>Success.</td><td>Status-bearing routines.</td></tr><tr><td><code>MTH_s_INVARGMAT</code></td><td><code>1475212</code></td><td>Invalid argument, for example arc cosine of a value outside minus one to one.</td><td><code>DACOS</code>, <code>DASIN</code>, <code>DATAN2</code>, the <code>ATANH</code> forms.</td></tr><tr><td><code>MTH_s_LOGZERNEG</code></td><td><code>1475228</code></td><td>Logarithm of zero or a negative value.</td><td><code>DLOG</code>, <code>DLOG10</code>, <code>DLOG2</code>.</td></tr><tr><td><code>MTH_s_SQUROONEG</code></td><td><code>1475236</code></td><td>Square root of a negative value.</td><td><code>DSQRT</code>.</td></tr><tr><td><code>MTH_s_FLOOVEMAT</code></td><td><code>1475268</code></td><td>Floating overflow.</td><td><code>DEXP</code>, <code>DTAN</code>, the hyperbolic forms, <code>DMOD</code>.</td></tr><tr><td><code>MTH_s_FLOUNDMAT</code></td><td><code>1475276</code></td><td>Floating underflow (gated, see below).</td><td><code>DEXP</code>, <code>DTAND</code>, <code>DSIND</code>.</td></tr></tbody></table></div><h6>Domain-guarded routines</h6><p>
Only the routines with a defined domain restriction test their operands and signal. Square
root guards against negatives, the logarithms guard against zero and negatives, the inverse
trigonometric routines guard their input range, and the exponential, tangent, hyperbolic, and
modulus routines guard against overflow. Every other routine returns its result without a
condition.
</p><div class="callout"><strong>Underflow reporting is gated.</strong> The floating-underflow condition is raised
only when the runtime configuration option <code>VX_UNDERFLOW_ENABLE</code> is set. Unless it
is enabled, an underflow is treated as a quiet zero rather than a signalled condition, so
applications that previously depended on an underflow signal should set the option during
migration testing.
</div><h2 id="porting">Porting notes and behavioural differences</h2><p>
VX/MTH$ preserves OpenVMS computation behaviour for the overwhelming majority of routines, so
applications that rely on MTH$ services migrate without rewriting the mathematical code. A
small number of routines have documented behavioural differences from the VAX and Alpha
originals, listed here so a porting team can account for them during testing rather than
discover them in production.
</p><div class="table-wrapper"><table><thead><tr><th>Area</th><th>Behaviour to check</th></tr></thead><tbody><tr><td>Forward trigonometry in degrees</td><td>The forward degree-input routines (<code>SIND</code>, <code>COSD</code>, <code>TAND</code> and their precision variants) diverge from the OpenVMS result and should be verified before an application relies on them. The inverse degree routines (<code>ASIND</code>, <code>ACOSD</code>, <code>ATAND</code>) match OpenVMS.</td></tr><tr><td>Truncation input mutation</td><td><code>DINT</code> (and <code>GINT</code> and <code>HINT</code>, which call it) can modify the caller's input value for negative operands. Pass a copy if the original value is needed after the call. <code>AINT</code> is unaffected.</td></tr><tr><td>Integer bit shift direction</td><td><code>IISHFT</code> and <code>JISHFT</code> interpret the sign of the shift count opposite to the Fortran <code>ISHFT</code> convention. Negate the shift count when porting code that assumed the Fortran direction.</td></tr><tr><td>Nearest-integer rounding at the half boundary</td><td><code>DNINT</code> rounds a negative value ending in .5 toward positive infinity rather than away from zero, so <code>DNINT(-2.5)</code> yields -2.0. Confirm rounding-sensitive financial calculations.</td></tr><tr><td>Double modulus</td><td><code>DMOD</code> uses a custom remainder rather than the host library, and its overflow and underflow detection is less reliable for negative divisors. Check results where the divisor can be negative.</td></tr><tr><td>Pseudo-random quality</td><td><code>MTH$RANDOM</code> is a low-quality generator suitable only for compatibility, not for statistical or cryptographic use. Replace it where distribution quality matters.</td></tr><tr><td>Hardware exception trapping</td><td>The SIGFPE trapping path is not enabled, so a hardware floating overflow yields a large value or NaN rather than a VMS condition, except in the routines that explicitly test for it. Applications that relied on trapped exceptions should validate their error paths.</td></tr><tr><td>No reserved-operand or null-pointer checks</td><td>Reserved and subnormal operands pass through as ordinary IEEE values, and a null argument pointer is not checked. Validate pointers before the call as you would in any C interface.</td></tr><tr><td>Extended-precision range</td><td>The h-float family delegates to IEEE <code>double</code>, so code that depended on the original h-float range or extra precision will see standard double behaviour. Review any calculation that relied on the wider VAX h-float format.</td></tr></tbody></table></div><div class="callout"><strong>Migration sizing.</strong> When scoping a port, check your application's actual MTH$
call inventory against this list. A small number of rarely used entry points are declared but
prioritised on demand; Sector7 completes them as migrations require them, so flag any
dependency during the porting assessment.
</div><h2 id="quickref">Quick reference</h2><h6>Key facts</h6><div class="table-wrapper"><table><thead><tr><th>Item</th><th>Value</th></tr></thead><tbody><tr><td>Public entry points</td><td>The full OpenVMS <code>MTH$</code> callable API surface</td></tr><tr><td>Delivery</td><td>Linked into the application via <code>libvxrt.a</code>, inside VX/RT</td></tr><tr><td>Platforms</td><td>x86 and ARM Linux</td></tr><tr><td>Internal arithmetic</td><td>IEEE-754 <code>double</code> for all precision families</td></tr><tr><td>Argument passing</td><td>All arguments by reference; result by value, except the h-float family</td></tr><tr><td>Variadic min and max</td><td>Leading count argument equal to operand count minus one</td></tr><tr><td>Domain errors</td><td>Raised as VMS conditions through the LIB$ signal path</td></tr></tbody></table></div><h6>Call-name forms per routine</h6><div class="kw-grid"><div>MTH$DSQRT</div><div>mth$dsqrt</div><div>MTH$DSQRT_</div><div>mth$dsqrt_</div></div><h6>Trigonometry routines</h6><div class="kw-grid"><div>MTH$SIN</div><div>MTH$COS</div><div>MTH$TAN</div><div>MTH$SIND</div><div>MTH$COSD</div><div>MTH$TAND</div><div>MTH$ASIN</div><div>MTH$ACOS</div><div>MTH$ATAN</div><div>MTH$ATAN2</div><div>MTH$SINCOS</div><div>MTH$DSIN</div></div><h6>Exponential, logarithm and root routines</h6><div class="kw-grid"><div>MTH$EXP</div><div>MTH$DEXP</div><div>MTH$ALOG</div><div>MTH$DLOG</div><div>MTH$ALOG10</div><div>MTH$DLOG10</div><div>MTH$ALOG2</div><div>MTH$DLOG2</div><div>MTH$SQRT</div><div>MTH$DSQRT</div><div>MTH$GSQRT</div><div>MTH$HSQRT</div></div><h6>Hyperbolic routines</h6><div class="kw-grid"><div>MTH$SINH</div><div>MTH$COSH</div><div>MTH$TANH</div><div>MTH$DSINH</div><div>MTH$DCOSH</div><div>MTH$DTANH</div><div>MTH$HSINH</div><div>MTH$HTANH</div></div><h6>Minimum, maximum and sign routines</h6><div class="kw-grid"><div>MTH$AMAX1</div><div>MTH$AMIN1</div><div>MTH$DMAX1</div><div>MTH$DMIN1</div><div>MTH$IMAX0</div><div>MTH$IMIN0</div><div>MTH$UMAX</div><div>MTH$UMIN</div><div>MTH$SIGN</div><div>MTH$DSIGN</div><div>MTH$SGN</div><div>MTH$DABS</div></div><h6>Integer and bitwise routines</h6><div class="kw-grid"><div>MTH$IIABS</div><div>MTH$IIAND</div><div>MTH$IIOR</div><div>MTH$IIEOR</div><div>MTH$INOT</div><div>MTH$IISHFT</div><div>MTH$IISIGN</div><div>MTH$IIDIM</div></div><h6>Conversion routines</h6><div class="kw-grid"><div>MTH$DBLE</div><div>MTH$SNGL</div><div>MTH$SNGLG</div><div>MTH$FLOATI</div><div>MTH$FLOATJ</div><div>MTH$DFLOTI</div><div>MTH$DFLOTJ</div><div>MTH$CVT_G_D</div></div></div>