From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d4db,d62d3891838b0a8f,start X-Google-Attributes: gid10d4db,public X-Google-ArrivalTime: 2003-05-21 15:05:03 PST Return-Path: Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cola.stump.algebra.com!robomod!not-for-mail X-COLA-Policy: http://stump.algebra.com/~cola X-COLA-Info-1: Send submissions to cola@stump.algebra.com X-COLA-Info-2: Send complaints to cola-admin@stump.algebra.com X-Comment: moderators do not necessarily agree or disagree with this article. X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov) Date: Wed, 21 May 2003 17:00:18 CST From: Tom Crane Message-ID: <030521224645.76ca4@mail.rhbnc.ac.uk> Subject: ANNOUNCE: g77_i386_fpe_demo (Demonstrates trapping floating-point exceptions under g77/i386/Linux) - resend Newsgroups: comp.os.linux.announce X-Auth: PGPMoose V1.1 PGP comp.os.linux.announce iQBVAwUAPsv29CFvAtx2nXvNAQGaDwH+MKNOI1gdV6VIjCIl/uA3jv/s9Gg6J0PE LTfuWliO2KtrHHnINreIe/N5S3VegQjizNhYFiyOCE0/PQ12vFWXMQ== =lXIc X-Spam-Status: No, hits=0.8 required=10.0 tests=FROM_ENDS_IN_NUMS,MISSING_HEADERS version=2.53 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.53 (1.174.2.15-2003-03-30-exp) Xref: archiver1.google.com comp.os.linux.announce:3315 g77_i386_fpe_demo is a very simple demonstration of trapping and handling floating-point exceptions under g77/i386/Linux. >>From the README.TXT... This small S/W package demonstrates handling of floating point exceptions (FPEs) under g77/i386/Linux. By default exceptions are not generated and serious errors such has sqrt(-ve number) and x/0.0 result in IEEE NaN and (+/-) INF propagating through the program. Having learnt FORTRAN programming under another platform (DEC VMS) where serious floating point errors always generate exceptions and the program terminates, I found the default behaviour under g77/i386/Linux quite disconcerting. There are several tips to be found on Usenet and on the gcc website, eg. http://gcc.gnu.org/onlinedocs/gcc-3.0.3/g77_20.html#SEC643 for dealing with this situation but no complete worked examples showing the creation and usage of FPE handlers under g77/i386/Linux. This package comprises two simple FORTRAN calling programs which demonstrate handling and trapping the six types of FPEs generated by the i387 FPU in accordance with the IEEE standard, IEEE-754, namely, (1) Invalid operation (2) Denormalised result (3) Division by zero (4) Overflow (5) Underflow (6) Precision loss (inexact result) Probably, the most useful default settings are to trap exceptions; 1, 3 & 4 above. Alternatively, when running the programs under the GNU debugger gdb, gdb's own exception handlers trap the FPEs. Debugger commands such as 'list' and 'bt' can be used to locate the line/calling sequence which generated the exception. The 'info float' command can then be used to examine the status of the FPU. This software is released under the GNU GPL. See http://www.mklab.rhul.ac.uk/~tom/g77_i386_fpe_demo/index.html Tom Crane. -- Tom Crane, Dept. Physics, Royal Holloway, University of London, Egham Hill, Egham, Surrey, TW20 0EX, England. Email: T.Crane@rhul.ac.uk SPAN: 19.875 Fax: +44 (0) 1784 472794 ########################################################################## # Send submissions for comp.os.linux.announce to: cola@stump.algebra.com # # PLEASE remember a short description of the software and the LOCATION. # # This group is archived at http://stump.algebra.com/~cola/ # ##########################################################################