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

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

unix.superglobalmegacorp.com

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