logbd32(), logbd64(), logbd128() — Unbiased exponent
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
C/C++ DFP | both | z/OS® V1.8 |
Format
#define __STDC_WANT_DEC_FP__
#include <math.h>
_Decimal32 logbd32(_Decimal32 x);
_Decimal64 logbd64(_Decimal64 x);
_Decimal128 logbd128(_Decimal128 x);
_Decimal32 logb(_Decimal32 x); /* C++ only */
_Decimal64 logb(_Decimal64 x); /* C++ only */
_Decimal128 logb(_Decimal128 x); /* C++ only */
General description
Returns the unbiased
exponent of its argument x as a signed integer
value in decimal floating-point mode. For typical numbers, the value
returned is the logarithm of |x| rounded
down (toward -INF) to the nearest integer value.
Notes:
- To use IEEE decimal floating-point, the hardware must have the Decimal Floating-Point Facility installed.
- These functions work in IEEE decimal floating-point format. See "IEEE Decimal Floating-Point" for more information.
Returned value
If successful, these functions return the unbiased exponent of x as a signed integer value in decimal floating-point mode.
These functions will fail under the following condition: If x is equal to 0.0, -HUGE_VAL_D32, -HUGE_VAL_D64, or -HUGE_VAL_D128 is returned and errno is set to EDOM.
Example
/* CELEBL24
This program illustrates the use of logbd32() function
*/
#define __STDC_WANT_DEC_FP__
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
void main()
{
_Decimal32 x, logbx;
printf("Illustrates the logbd32() function\n");
/* Generate the smallest possible positive _Decimal32 number */
x = strtod32("0000001.E-101", NULL);
logbx = logbd32(x);
printf("x = %Hg\n" , x );
printf("logb(x) = %Hf\n\n", logbx);
printf("powd32(10.0, logb32(x)) should equal x\n");
printf("powd32(%Hf, %Hf) = %Hg\n",
10.0DF, logbx, powd32(10.0DF, logbx));
}