|
Packit |
67cb25 |
/* ieee-utils/gsl_ieee_utils.h
|
|
Packit |
67cb25 |
*
|
|
Packit |
67cb25 |
* Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough
|
|
Packit |
67cb25 |
*
|
|
Packit |
67cb25 |
* This program is free software; you can redistribute it and/or modify
|
|
Packit |
67cb25 |
* it under the terms of the GNU General Public License as published by
|
|
Packit |
67cb25 |
* the Free Software Foundation; either version 3 of the License, or (at
|
|
Packit |
67cb25 |
* your option) any later version.
|
|
Packit |
67cb25 |
*
|
|
Packit |
67cb25 |
* This program is distributed in the hope that it will be useful, but
|
|
Packit |
67cb25 |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
67cb25 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
67cb25 |
* General Public License for more details.
|
|
Packit |
67cb25 |
*
|
|
Packit |
67cb25 |
* You should have received a copy of the GNU General Public License
|
|
Packit |
67cb25 |
* along with this program; if not, write to the Free Software
|
|
Packit |
67cb25 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
Packit |
67cb25 |
*/
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
#ifndef __GSL_IEEE_UTILS_H__
|
|
Packit |
67cb25 |
#define __GSL_IEEE_UTILS_H__
|
|
Packit |
67cb25 |
#include <stdio.h>
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
#undef __BEGIN_DECLS
|
|
Packit |
67cb25 |
#undef __END_DECLS
|
|
Packit |
67cb25 |
#ifdef __cplusplus
|
|
Packit |
67cb25 |
# define __BEGIN_DECLS extern "C" {
|
|
Packit |
67cb25 |
# define __END_DECLS }
|
|
Packit |
67cb25 |
#else
|
|
Packit |
67cb25 |
# define __BEGIN_DECLS /* empty */
|
|
Packit |
67cb25 |
# define __END_DECLS /* empty */
|
|
Packit |
67cb25 |
#endif
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
__BEGIN_DECLS
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
enum {
|
|
Packit |
67cb25 |
GSL_IEEE_TYPE_NAN = 1,
|
|
Packit |
67cb25 |
GSL_IEEE_TYPE_INF = 2,
|
|
Packit |
67cb25 |
GSL_IEEE_TYPE_NORMAL = 3,
|
|
Packit |
67cb25 |
GSL_IEEE_TYPE_DENORMAL = 4,
|
|
Packit |
67cb25 |
GSL_IEEE_TYPE_ZERO = 5
|
|
Packit |
67cb25 |
} ;
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
typedef struct {
|
|
Packit |
67cb25 |
int sign ;
|
|
Packit |
67cb25 |
char mantissa[24] ; /* Actual bits are 0..22, element 23 is \0 */
|
|
Packit |
67cb25 |
int exponent ;
|
|
Packit |
67cb25 |
int type ;
|
|
Packit |
67cb25 |
} gsl_ieee_float_rep ;
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
typedef struct {
|
|
Packit |
67cb25 |
int sign ;
|
|
Packit |
67cb25 |
char mantissa[53] ; /* Actual bits are 0..51, element 52 is \0 */
|
|
Packit |
67cb25 |
int exponent ;
|
|
Packit |
67cb25 |
int type ;
|
|
Packit |
67cb25 |
} gsl_ieee_double_rep ;
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
void gsl_ieee_printf_float (const float * x) ;
|
|
Packit |
67cb25 |
void gsl_ieee_printf_double (const double * x) ;
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
void gsl_ieee_fprintf_float (FILE * stream, const float * x) ;
|
|
Packit |
67cb25 |
void gsl_ieee_fprintf_double (FILE * stream, const double * x) ;
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
void gsl_ieee_float_to_rep (const float * x, gsl_ieee_float_rep * r) ;
|
|
Packit |
67cb25 |
void gsl_ieee_double_to_rep (const double * x, gsl_ieee_double_rep * r) ;
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
enum {
|
|
Packit |
67cb25 |
GSL_IEEE_SINGLE_PRECISION = 1,
|
|
Packit |
67cb25 |
GSL_IEEE_DOUBLE_PRECISION = 2,
|
|
Packit |
67cb25 |
GSL_IEEE_EXTENDED_PRECISION = 3
|
|
Packit |
67cb25 |
} ;
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
enum {
|
|
Packit |
67cb25 |
GSL_IEEE_ROUND_TO_NEAREST = 1,
|
|
Packit |
67cb25 |
GSL_IEEE_ROUND_DOWN = 2,
|
|
Packit |
67cb25 |
GSL_IEEE_ROUND_UP = 3,
|
|
Packit |
67cb25 |
GSL_IEEE_ROUND_TO_ZERO = 4
|
|
Packit |
67cb25 |
} ;
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
enum {
|
|
Packit |
67cb25 |
GSL_IEEE_MASK_INVALID = 1,
|
|
Packit |
67cb25 |
GSL_IEEE_MASK_DENORMALIZED = 2,
|
|
Packit |
67cb25 |
GSL_IEEE_MASK_DIVISION_BY_ZERO = 4,
|
|
Packit |
67cb25 |
GSL_IEEE_MASK_OVERFLOW = 8,
|
|
Packit |
67cb25 |
GSL_IEEE_MASK_UNDERFLOW = 16,
|
|
Packit |
67cb25 |
GSL_IEEE_MASK_ALL = 31,
|
|
Packit |
67cb25 |
GSL_IEEE_TRAP_INEXACT = 32
|
|
Packit |
67cb25 |
} ;
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
void gsl_ieee_env_setup (void) ;
|
|
Packit |
67cb25 |
int gsl_ieee_read_mode_string (const char * description, int * precision,
|
|
Packit |
67cb25 |
int * rounding, int * exception_mask) ;
|
|
Packit |
67cb25 |
int gsl_ieee_set_mode (int precision, int rounding, int exception_mask) ;
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
__END_DECLS
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
#endif /* __GSL_IEEE_UTILS_H__ */
|
|
Packit |
67cb25 |
|