📄 test_float
字号:
#ifndef lintstatic char "sccs = @(#)Test_float 4.1 (ULTRIX) 7/3/90";#endif lint/************************************************************************ * * * Copyright (c) 1983 by * * Digital Equipment Corporation, Maynard, MA * * All rights reserved. * * * * This software is furnished under a license and may be used and * * copied only in accordance with the terms of such license and * * with the inclusion of the above copyright notice. This * * software or any other copies thereof may not be provided or * * otherwise made available to any other person. No title to and * * ownership of the software is hereby transferred. * * * * This software is derived from software received from the * * University of California, Berkeley, and from Bell * * Laboratories. Use, duplication, or disclosure is subject to * * restrictions under license agreements with University of * * California and with AT&T. * * * * The information in this software is subject to change without * * notice and should not be construed as a commitment by Digital * * Equipment Corporation. * * * * Digital assumes no responsibility for the use or reliability * * of its software on equipment which is not supplied by Digital. * * * ************************************************************************//************************************************************************** Modification History** David Metsky 13-Jan-86** 001 Added from BSD 4.3 version as part of upgrade.**************************************************************************/#! /bin/csh -f ## this tests if C rounds the return value to single precision in# functions of type float. (see sec. 9.10 of C ref. manual).#cat << 'EOT' >! /tmp/test_fltc.cfloat temp;float f1_(arg1,arg2)float *arg1, *arg2;{ /* force float by storing in global */ temp = *arg1 / *arg2; return temp;}float f2_(arg1,arg2)float *arg1, *arg2;{ /* should round since function is type float */ return *arg1 / *arg2;}float f3_(arg1,arg2)float *arg1, *arg2;{ /* use a cast to try to force rounding */ return ((float) (*arg1 / *arg2));}'EOT'cat << 'EOT' >! /tmp/test_fltf.f integer f2ok, f3ok data f2ok/0/, f3ok/0/ do 20 i = 1,10 do 10 j = 1,10 x = 0.1d0*i y = 0.1d0*j temp = f1(x,y) if( f2(x,y).eq.temp) f2ok = f2ok + 1 if( f3(x,y).eq.temp) f3ok = f3ok + 110 continue20 continue print *, "out of 100 tries, f2 was ok", f2ok, "times" print *, "out of 100 tries, f3 was ok", f3ok, "times" end'EOT'pushd /tmpf77 test_fltc.c test_fltf.f -o test_flttest_flt
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -