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