public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Exception catching
@ 2001-11-06 12:48 Hassan Aurag
  2001-11-06 15:04 ` Toon Moene
  0 siblings, 1 reply; 2+ messages in thread
From: Hassan Aurag @ 2001-11-06 12:48 UTC (permalink / raw)
  To: GCC Help Mailing List


 I would like an example on how to catch all division by zeros in
Fortran.

 My idea is the following in pseudo-code:

 num, denom = catch_div_byzero()

 return bignumber (and not nan)

 Is this even possible?

 In other words, I would like to alter division by zero so that it
returns a huge number. can it be made even in C and then linked as
library to my fortran code?




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Exception catching
  2001-11-06 12:48 Exception catching Hassan Aurag
@ 2001-11-06 15:04 ` Toon Moene
  0 siblings, 0 replies; 2+ messages in thread
From: Toon Moene @ 2001-11-06 15:04 UTC (permalink / raw)
  To: Hassan Aurag; +Cc: GCC Help Mailing List

Hassan Aurag wrote:

>  I would like an example on how to catch all division by zeros in
> Fortran.
> 
>  My idea is the following in pseudo-code:
> 
>  num, denom = catch_div_byzero()
> 
>  return bignumber (and not nan)
> 
>  Is this even possible?

I presume you mean "possible without changing my Fortran source code" ?

>  In other words, I would like to alter division by zero so that it
> returns a huge number. can it be made even in C and then linked as
> library to my fortran code?

No, because the division is done "inline", i.e., no subroutine call is
generated.

However, you might be able to set the floating point control word in
your processor to catch this error instead of silently generating a NaN.

See http://gcc.gnu.org/onlinedocs/g77_19.html#SEC644

[Note that this is really a C library question - notably a glibc
 enabled solution]

Hope this helps,

-- 
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-11-16 20:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-06 12:48 Exception catching Hassan Aurag
2001-11-06 15:04 ` Toon Moene

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).