Annotation of coherent/b/lib/libc/gen/ieee_f.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * libc/gen/ieee_f.c
                      3:  */
                      4: 
                      5: /*
                      6:  * ieee_f(float *ifp, float *dfp)
                      7:  * Convert float from DECVAX format to IEEE format.
                      8:  * dfp points to a DECVAX format float to convert.
                      9:  * ifp points to a destination for the converted IEEE value;
                     10:  * ifp may be identical to dfp for in-place conversion.
                     11:  * The significand remains unchanged.
                     12:  * Returns 0 if successful, -1 on underflow.
                     13:  */
                     14: 
                     15: int
                     16: ieee_f(ifp, dfp) float *ifp, *dfp;
                     17: {
                     18:        register int exp;
                     19:        register unsigned char *cp;
                     20: 
                     21:        /* Copy to destination. */
                     22:        cp = (char *)ifp;
                     23:        if (ifp != dfp)
                     24:                memcpy(cp, (char *)dfp, sizeof(float));
                     25: 
                     26:        /* Adjust exponent bias from 129 to 127. */
                     27:        exp = ((cp[3] & 0x7F) << 1) | ((cp[2] & 0x80) >> 7);
                     28:        if (exp == 0)
                     29:                return 0;
                     30:        else if (exp > 2) {
                     31:                /* Subtract 2 by decrementing the low bit of the hi byte. */
                     32:                --cp[3];
                     33:                return 0;
                     34:        }
                     35: 
                     36:        /* Exponent underflow. */
                     37:        cp[3] = cp[2] = cp[1] = cp[0] = 0;
                     38:        return -1;
                     39: }
                     40: 
                     41: /* end of libc/gen/ieee_f.c */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.