Annotation of 43BSD/usr.lib/libF77/pow_ri.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1980 Regents of the University of California.
                      3:  * All rights reserved.  The Berkeley software License Agreement
                      4:  * specifies the terms and conditions for redistribution.
                      5:  *
                      6:  *     @(#)pow_ri.c    5.2     7/9/85
                      7:  */
                      8: 
                      9: float flt_retval;
                     10: 
                     11: float pow_ri(ap, bp)
                     12: float *ap;
                     13: long int *bp;
                     14: {
                     15: double pow, x;
                     16: long int n;
                     17: 
                     18: pow = 1;
                     19: x = *ap;
                     20: n = *bp;
                     21: 
                     22: if(n != 0)
                     23:        {
                     24:        if(n < 0)
                     25:                {
                     26:                if(x == 0)
                     27:                        {
                     28:                        flt_retval = pow;
                     29:                        return(flt_retval);
                     30:                        }
                     31:                n = -n;
                     32:                x = 1/x;
                     33:                }
                     34:        for( ; ; )
                     35:                {
                     36:                if(n & 01)
                     37:                        pow *= x;
                     38:                if(n >>= 1)
                     39:                        x *= x;
                     40:                else
                     41:                        break;
                     42:                }
                     43:        }
                     44: flt_retval = pow;
                     45: return(flt_retval);
                     46: }

unix.superglobalmegacorp.com

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