Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:03:48

0001 /* ieee-utils/gsl_ieee_utils.h
0002  * 
0003  * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough
0004  * 
0005  * This program is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation; either version 3 of the License, or (at
0008  * your option) any later version.
0009  * 
0010  * This program is distributed in the hope that it will be useful, but
0011  * WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * General Public License for more details.
0014  * 
0015  * You should have received a copy of the GNU General Public License
0016  * along with this program; if not, write to the Free Software
0017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #ifndef __GSL_IEEE_UTILS_H__
0021 #define __GSL_IEEE_UTILS_H__
0022 #include <stdio.h>
0023 
0024 #undef __BEGIN_DECLS
0025 #undef __END_DECLS
0026 #ifdef __cplusplus
0027 # define __BEGIN_DECLS extern "C" {
0028 # define __END_DECLS }
0029 #else
0030 # define __BEGIN_DECLS /* empty */
0031 # define __END_DECLS /* empty */
0032 #endif
0033 
0034 __BEGIN_DECLS
0035 
0036 enum {
0037   GSL_IEEE_TYPE_NAN = 1,
0038   GSL_IEEE_TYPE_INF = 2,
0039   GSL_IEEE_TYPE_NORMAL = 3,
0040   GSL_IEEE_TYPE_DENORMAL = 4,
0041   GSL_IEEE_TYPE_ZERO = 5
0042 } ;
0043 
0044 typedef struct  {
0045   int sign ;
0046   char mantissa[24] ; /* Actual bits are 0..22, element 23 is \0 */
0047   int exponent ;
0048   int type ;
0049 } gsl_ieee_float_rep ;
0050 
0051 typedef struct  {
0052   int sign ;
0053   char mantissa[53] ; /* Actual bits are 0..51, element 52 is \0 */
0054   int exponent ;
0055   int type ;
0056 } gsl_ieee_double_rep ;
0057 
0058 
0059 void gsl_ieee_printf_float (const float * x) ;
0060 void gsl_ieee_printf_double (const double * x) ;
0061 
0062 void gsl_ieee_fprintf_float (FILE * stream, const float * x) ;
0063 void gsl_ieee_fprintf_double (FILE * stream, const double * x) ;
0064 
0065 void gsl_ieee_float_to_rep (const float * x, gsl_ieee_float_rep * r) ;
0066 void gsl_ieee_double_to_rep (const double * x, gsl_ieee_double_rep * r) ;
0067 
0068 enum {
0069   GSL_IEEE_SINGLE_PRECISION = 1,
0070   GSL_IEEE_DOUBLE_PRECISION = 2,
0071   GSL_IEEE_EXTENDED_PRECISION = 3
0072 } ;
0073 
0074 enum {
0075   GSL_IEEE_ROUND_TO_NEAREST = 1,
0076   GSL_IEEE_ROUND_DOWN = 2,
0077   GSL_IEEE_ROUND_UP = 3,
0078   GSL_IEEE_ROUND_TO_ZERO = 4
0079 } ;
0080 
0081 enum {
0082   GSL_IEEE_MASK_INVALID = 1,
0083   GSL_IEEE_MASK_DENORMALIZED = 2,
0084   GSL_IEEE_MASK_DIVISION_BY_ZERO = 4,
0085   GSL_IEEE_MASK_OVERFLOW = 8,
0086   GSL_IEEE_MASK_UNDERFLOW = 16,
0087   GSL_IEEE_MASK_ALL = 31,
0088   GSL_IEEE_TRAP_INEXACT = 32
0089 } ;
0090 
0091 void gsl_ieee_env_setup (void) ;
0092 int gsl_ieee_read_mode_string (const char * description, int * precision,
0093                                int * rounding, int * exception_mask) ;
0094 int gsl_ieee_set_mode (int precision, int rounding, int exception_mask) ;
0095 
0096 __END_DECLS
0097 
0098 #endif /* __GSL_IEEE_UTILS_H__ */
0099