Annotation of 43BSD/usr.lib/libF77/Test_float, revision 1.1

1.1     ! root        1: #!     /bin/csh -f 
        !             2: #
        !             3: #      this tests if C rounds the return value to single precision in
        !             4: #      functions of type float. (see sec. 9.10 of C ref. manual).
        !             5: #
        !             6: cat << 'EOT' >! /tmp/test_fltc.c
        !             7: float temp;
        !             8: 
        !             9: float f1_(arg1,arg2)
        !            10: float *arg1, *arg2;
        !            11: {
        !            12:        /* force float by storing in global */
        !            13:        temp =  *arg1 / *arg2;
        !            14:        return temp;
        !            15: }
        !            16: 
        !            17: float f2_(arg1,arg2)
        !            18: float *arg1, *arg2;
        !            19: {
        !            20:        /* should round since function is type float */
        !            21:        return  *arg1 / *arg2;
        !            22: }
        !            23: 
        !            24: 
        !            25: float f3_(arg1,arg2)
        !            26: float *arg1, *arg2;
        !            27: {
        !            28:        /* use a cast to try to force rounding */
        !            29:        return ((float) (*arg1 / *arg2));
        !            30: }
        !            31: 
        !            32: 'EOT'
        !            33: cat << 'EOT' >! /tmp/test_fltf.f
        !            34:        integer f2ok, f3ok
        !            35:        data f2ok/0/, f3ok/0/
        !            36: 
        !            37:        do 20 i = 1,10
        !            38:        do 10 j = 1,10
        !            39:        x = 0.1d0*i
        !            40:        y = 0.1d0*j
        !            41:        temp = f1(x,y)
        !            42:        if( f2(x,y).eq.temp) f2ok = f2ok + 1
        !            43:        if( f3(x,y).eq.temp) f3ok = f3ok + 1
        !            44: 10     continue
        !            45: 20     continue
        !            46:        print *, "out of 100 tries, f2 was ok", f2ok, "times"
        !            47:        print *, "out of 100 tries, f3 was ok", f3ok, "times"
        !            48:        end
        !            49: 'EOT'
        !            50: pushd /tmp
        !            51: f77 test_fltc.c test_fltf.f -o test_flt
        !            52: test_flt

unix.superglobalmegacorp.com

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