#include <packed.h> double pdval(const char (*val)[], unsigned int scale);
pdval
converts val
, a number in packed-decimal format, to its
floating-point representation. The maximum length of val
is 8
bytes (15 decimal digits). After conversion, val
is multiplied by
pow(10.0, -scale)
. scale
, which specifies a scaling factor,
must be a nonnegative integer less than or equal to 15.
val
, appropriately scaled.
val
does not contain valid packed-decimal data, an 0C7 ABEND
results.
scale
is not positive and less than or equal to 15, then pdval
returns HUGE_VAL
and sets errno
to EARG.
pdval
is defined in <packed.h>
as
#define pdval(val, scale) _pdval(val, sizeof(*val), scale)
#include <packed.h> #include <stdio.h> void printamt(char (*amount)[6]) /* expected COBOL data declaration: */ /* AMOUNT PIC 9(9)V99 COMP-3. */ { double dollars; /* Convert to dollars and cents. */ dollars = pdval(amount, 2); printf("Amount is $ % 12.2fn", dollars); return; }
pdset
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.