1 /* ieee-utils/gsl_ieee_utils.h
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef __GSL_IEEE_UTILS_H__
21 #define __GSL_IEEE_UTILS_H__
27 # define __BEGIN_DECLS extern "C" {
28 # define __END_DECLS }
30 # define __BEGIN_DECLS /* empty */
31 # define __END_DECLS /* empty */
37 GSL_IEEE_TYPE_NAN = 1,
38 GSL_IEEE_TYPE_INF = 2,
39 GSL_IEEE_TYPE_NORMAL = 3,
40 GSL_IEEE_TYPE_DENORMAL = 4,
41 GSL_IEEE_TYPE_ZERO = 5
46 char mantissa[24] ; /* Actual bits are 0..22, element 23 is \0 */
49 } gsl_ieee_float_rep ;
53 char mantissa[53] ; /* Actual bits are 0..51, element 52 is \0 */
56 } gsl_ieee_double_rep ;
59 void gsl_ieee_printf_float (const float * x) ;
60 void gsl_ieee_printf_double (const double * x) ;
62 void gsl_ieee_fprintf_float (FILE * stream, const float * x) ;
63 void gsl_ieee_fprintf_double (FILE * stream, const double * x) ;
65 void gsl_ieee_float_to_rep (const float * x, gsl_ieee_float_rep * r) ;
66 void gsl_ieee_double_to_rep (const double * x, gsl_ieee_double_rep * r) ;
69 GSL_IEEE_SINGLE_PRECISION = 1,
70 GSL_IEEE_DOUBLE_PRECISION = 2,
71 GSL_IEEE_EXTENDED_PRECISION = 3
75 GSL_IEEE_ROUND_TO_NEAREST = 1,
76 GSL_IEEE_ROUND_DOWN = 2,
77 GSL_IEEE_ROUND_UP = 3,
78 GSL_IEEE_ROUND_TO_ZERO = 4
82 GSL_IEEE_MASK_INVALID = 1,
83 GSL_IEEE_MASK_DENORMALIZED = 2,
84 GSL_IEEE_MASK_DIVISION_BY_ZERO = 4,
85 GSL_IEEE_MASK_OVERFLOW = 8,
86 GSL_IEEE_MASK_UNDERFLOW = 16,
87 GSL_IEEE_MASK_ALL = 31,
88 GSL_IEEE_TRAP_INEXACT = 32
91 void gsl_ieee_env_setup (void) ;
92 int gsl_ieee_read_mode_string (const char * description, int * precision,
93 int * rounding, int * exception_mask) ;
94 int gsl_ieee_set_mode (int precision, int rounding, int exception_mask) ;
98 #endif /* __GSL_IEEE_UTILS_H__ */