3
<title>Handling floating point exceptions - GNU Scientific Library -- Reference Manual</title>
4
<meta http-equiv="Content-Type" content="text/html">
5
<meta name="description" content="GNU Scientific Library -- Reference Manual">
6
<meta name="generator" content="makeinfo 4.8">
7
<link title="Top" rel="start" href="index.html#Top">
8
<link rel="up" href="Debugging-Numerical-Programs.html#Debugging-Numerical-Programs" title="Debugging Numerical Programs">
9
<link rel="prev" href="Examining-floating-point-registers.html#Examining-floating-point-registers" title="Examining floating point registers">
10
<link rel="next" href="GCC-warning-options-for-numerical-programs.html#GCC-warning-options-for-numerical-programs" title="GCC warning options for numerical programs">
11
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
13
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 The GSL Team.
15
Permission is granted to copy, distribute and/or modify this document
16
under the terms of the GNU Free Documentation License, Version 1.2 or
17
any later version published by the Free Software Foundation; with the
18
Invariant Sections being ``GNU General Public License'' and ``Free Software
19
Needs Free Documentation'', the Front-Cover text being ``A GNU Manual'',
20
and with the Back-Cover Text being (a) (see below). A copy of the
21
license is included in the section entitled ``GNU Free Documentation
24
(a) The Back-Cover Text is: ``You have freedom to copy and modify this
25
GNU Manual, like GNU software.''-->
26
<meta http-equiv="Content-Style-Type" content="text/css">
27
<style type="text/css"><!--
28
pre.display { font-family:inherit }
29
pre.format { font-family:inherit }
30
pre.smalldisplay { font-family:inherit; font-size:smaller }
31
pre.smallformat { font-family:inherit; font-size:smaller }
32
pre.smallexample { font-size:smaller }
33
pre.smalllisp { font-size:smaller }
34
span.sc { font-variant:small-caps }
35
span.roman { font-family:serif; font-weight:normal; }
36
span.sansserif { font-family:sans-serif; font-weight:normal; }
42
<a name="Handling-floating-point-exceptions"></a>
43
Next: <a rel="next" accesskey="n" href="GCC-warning-options-for-numerical-programs.html#GCC-warning-options-for-numerical-programs">GCC warning options for numerical programs</a>,
44
Previous: <a rel="previous" accesskey="p" href="Examining-floating-point-registers.html#Examining-floating-point-registers">Examining floating point registers</a>,
45
Up: <a rel="up" accesskey="u" href="Debugging-Numerical-Programs.html#Debugging-Numerical-Programs">Debugging Numerical Programs</a>
49
<h3 class="section">A.3 Handling floating point exceptions</h3>
51
<p>It is possible to stop the program whenever a <code>SIGFPE</code> floating
52
point exception occurs. This can be useful for finding the cause of an
53
unexpected infinity or <code>NaN</code>. The current handler settings can be
54
shown with the command <code>info signal SIGFPE</code>.
56
<pre class="smallexample"> (gdb) info signal SIGFPE
57
Signal Stop Print Pass to program Description
58
SIGFPE Yes Yes Yes Arithmetic exception
60
<p class="noindent">Unless the program uses a signal handler the default setting should be
61
changed so that SIGFPE is not passed to the program, as this would cause
62
it to exit. The command <code>handle SIGFPE stop nopass</code> prevents this.
64
<pre class="smallexample"> (gdb) handle SIGFPE stop nopass
65
Signal Stop Print Pass to program Description
66
SIGFPE Yes Yes No Arithmetic exception
68
<p class="noindent">Depending on the platform it may be necessary to instruct the kernel to
69
generate signals for floating point exceptions. For programs using GSL
70
this can be achieved using the <code>GSL_IEEE_MODE</code> environment variable
71
in conjunction with the function <code>gsl_ieee_env_setup()</code> as described
72
in see <a href="IEEE-floating_002dpoint-arithmetic.html#IEEE-floating_002dpoint-arithmetic">IEEE floating-point arithmetic</a>.
74
<pre class="example"> (gdb) set env GSL_IEEE_MODE=double-precision