00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "FP_bias.h"
00030 #include "FP_shift.h"
00031 #include "FP_types.h"
00032 #include "get_put.h"
00033
00034
00035 void
00036 extend(from,to,size)
00037 unsigned long *from;
00038 EXTEND *to;
00039 int size;
00040 {
00041 register char *cpt1;
00042 unsigned long tmp;
00043 int leadbit = 0;
00044
00045 cpt1 = (char *) from;
00046
00047 #if FL_MSL_AT_LOW_ADDRESS
00048 #if FL_MSW_AT_LOW_ADDRESS
00049 to->exp = uget2(cpt1);
00050 #else
00051 to->exp = uget2(cpt1+2);
00052 #endif
00053 #else
00054 #if FL_MSW_AT_LOW_ADDRESS
00055 to->exp = uget2(cpt1+(size == sizeof(DOUBLE) ? 4 : 0));
00056 #else
00057 to->exp = uget2(cpt1+(size == sizeof(DOUBLE) ? 6 : 2));
00058 #endif
00059 #endif
00060 to->sign = (to->exp & 0x8000);
00061 to->exp ^= to->sign;
00062 if (size == sizeof(DOUBLE))
00063 to->exp >>= DBL_EXPSHIFT;
00064 else
00065 to->exp >>= SGL_EXPSHIFT;
00066 if (to->exp > 0)
00067 leadbit++;
00068 else to->exp++;
00069
00070 if (size == sizeof(DOUBLE)) {
00071 #if FL_MSL_AT_LOW_ADDRESS
00072 to->m1 = get4(cpt1);
00073 cpt1 += 4;
00074 tmp = get4(cpt1);
00075 #else
00076 tmp = get4(cpt1);
00077 cpt1 += 4;
00078 to->m1 = get4(cpt1);
00079 #endif
00080 if (to->exp == 1 && to->m1 == 0 && tmp == 0) {
00081 to->exp = 0;
00082 to->sign = 0;
00083 to->m1 = 0;
00084 to->m2 = 0;
00085 return;
00086 }
00087 to->m1 <<= DBL_M1LEFT;
00088 to->exp -= DBL_BIAS;
00089 to->m1 |= (tmp>>DBL_RPACK);
00090 to->m2 = (tmp<<DBL_LPACK);
00091 }
00092 else {
00093 to->m1 = get4(cpt1);
00094 to->m1 <<= SGL_M1LEFT;
00095 if (to->exp == 1 && to->m1 == 0) {
00096 to->exp = 0;
00097 to->sign = 0;
00098 to->m1 = 0;
00099 to->m2 = 0;
00100 return;
00101 }
00102 to->exp -= SGL_BIAS;
00103 to->m2 = 0L;
00104 }
00105
00106 to->m1 |= NORMBIT;
00107 if (leadbit == 0) {
00108 to->m1 &= ~NORMBIT;
00109 nrm_ext(to);
00110 }
00111 }