Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!bu.edu!snorkelwacker.mit.edu!mit-eddie!uw-beaver!zephyr.ens.tek.com!orca.wv.tek.com!bicycle!wallyk From: wallyk@bicycle.WV.TEK.COM (Wally Kramer) Newsgroups: comp.os.msdos.programmer Subject: Re: TC vs mainframe Keywords: tc Message-ID: <10821@orca.wv.tek.com> Date: 14 May 91 04:26:37 GMT References: <127293@unix.cis.pitt.edu> Sender: nobody@orca.wv.tek.com Reply-To: wallyk@bicycle.WV.TEK.COM (Wally Kramer) Organization: Tektronix, Inc., Wilsonville, Oregon Lines: 55 yding@unix.cis.pitt.edu (Yijun Ding ) writes: >Recently I have a program with small floatings. I find something works >on my TC but not on mainframe. The following code, log10() print >correctly on TC2.0. It is HUGE on unix, and 0 on VMS in University of >Pittsburgh. That is a surprise. > >#include >main() >{ > double a=1.12345e-40; > printf("%lf %lf\n", a, log10(a)); >} > >Any one can explain why? This might not be the appropriate place for this discussion, however, I myself frequently move software between VMS, Unix and MSDOS. For a Unix system, I used UTek (a BSD derivative) running on a 68020 and got the runtime result of 0.000000 -39.949446 which looks correct to me (and is the same as I got under TC++ 1.0). Naturally, for unix to link in a log10 function, you have to use cc small.c -lm On VMS, I also got the same result, but it was a little more trouble. $ cc /g_float small.c $ link small.obj, sys$input /option sys$share:vaxcrtlg /share ^Z $ run small 0.000000 -39.949446 The problem here is that the VAX floating point range used by default is D_floating: Mantissa Approx. Bits Range bits significant digits F_floating 32 .298e-38 to 1.7e+38 23 6-7 D_floating 64 .298e-38 to 1.7e+38 55 15 G_floating 64 .56e-308 to .9e+308 53 15 VAXC, by default, uses F_float for "float" (unless the /precision=double qualifier is used) and D_floats for "double". For the magnitude of value you want to use, you should use the /g_float qualifier in *all* your compilations. Observe also that you link against VAXCRTLG.EXE instead of VAXCRTL.EXE so that the library routines use G_floats. ----- Wally Kramer contracted from Step Technology, Portland, Oregon 503 244 1239 wallyk@orca.wv.tek.com +1 503 685 2658