/* real2prim.c - real to presentation element */
static char *rcsid
= "$Header: /f/osi/psap/RCS/real2prim.c,v 7.1 91/02/22 09:36:50 mrose Interim $";
* $Header: /f/osi/psap/RCS/real2prim.c,v 7.1 91/02/22 09:36:50 mrose Interim $
* Contributed by Julian Onions, Nottingham University.
* July 1989 - this is awful stuff!
* Revision 7.1 91/02/22 09:36:50 mrose
* Revision 7.0 89/11/23 22:13:34 mrose
* Acquisition, use, and distribution of this module and related
* materials are subject to the restrictions of a license agreement.
* Consult the Preface in the User's Manual for the full terms of
PE
real2prim (d
, class, id
)
int parts
[sizeof (double)];
if ((pe
= pe_alloc (class, PE_FORM_PRIM
, id
)) == NULLPE
)
mant
= frexp (d
, &exponent
);
for (i
= 0; i
< sizeof (double) ; i
++) {
intnm
= ((int)nm
) & 0xff;
expsign
= exponent
>= 0 ? exponent
: exponent
^ (-1);
mask
= 0x1ff << (((n
= sizeof exponent
) - 1) * 8 - 1);
while (n
> 1 && (expsign
& mask
) == 0)
if ((pe
-> pe_prim
= PEDalloc (n
+ maxi
+ 1)) == NULLPED
) {
dp
= pe
-> pe_prim
+ (pe
-> pe_len
= n
+ maxi
+ 1);
for (; maxi
> 0; maxi
--)
for (n
= explen
; n
-- > 0; exponent
>>= 8)
| (sign
== -1 ? PE_REAL_B_S
: 0)