remainderd32(), remainderd64(), remainderd128() - Computes the remainder x REM y

Standards

Standards / Extensions C or C++ Dependencies

C/C++ DFP

both z/OS® V1.10

Format

#define __STDC_WANT_DEC_FP__
#include <math.h>

_Decimal32  remainderd32(_Decimal32 x, _Decimal32 y);
_Decimal64  remainderd64(_Decimal64 x, _Decimal64 y);
_Decimal128 remainderd128(_Decimal128 x, _Decimal128 y);

_Decimal32  remainder(_Decimal32 x, _Decimal32 y);     /* C++ only */
_Decimal64  remainder(_Decimal64 x, _Decimal64 y);     /* C++ only */
_Decimal128 remainder(_Decimal128 x, _Decimal128 y);    /* C++ only */

General description

The remainder() function returns the decimal floating-point remainder when y is nonzero and following the relation
Formula of the functions
The value n is the integral value nearest the exact value x/y and when
Formula of the functions
then the value of n is even.

These functions work in IEEE decimal floating-point format. See IEEE decimal floating-point for more information.

Note: To use IEEE decimal floating-point, the hardware must have the Decimal Floating-Point Facility installed.

Returned value

If successful, remainder() returns the remainder of the division of x by y.

If y is zero, remainder() returns NaNQ and sets errno to EDOM.

Example

CELEBR23
⁄* CELEBR23

   This example illustrates the remainderd32() function.

*⁄

#define __STDC_WANT_DEC_FP__
#include <math.h>
#include <stdio.h>

void main() {
  _Decimal32 n1=3.0DF, n2=3.5DF;

  printf("Illustrates the remainderd32() function\n");

  printf("remainderd32(%.2Hf,%.2Hf)=%.2Hf\n",n1,n2,remainderd32(n1,n2));
  n1=1.0DF; n2=2.0DF;
  printf("remainderd32(%.2Hf,%.2Hf)=%.2Hf\n",n1,n2,remainderd32(n1,n2));
  n1=1.0DF; n2=0.0DF;
  printf("remainderd32(%.2Hf,%.2Hf)=%.2Hf\n",n1,n2,remainderd32(n1,n2));
}

Related information