Remove "Written by Ben Pfaff <blp@gnu.org>" lines everywhere.
[pspp-builds.git] / src / libpspp / float-format.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 2006 Free Software Foundation, Inc.
3
4    This program is free software; you can redistribute it and/or
5    modify it under the terms of the GNU General Public License as
6    published by the Free Software Foundation; either version 2 of the
7    License, or (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful, but
10    WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software
16    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17    02110-1301, USA. */
18
19 #ifndef LIBPSPP_FLOAT_FORMAT_H
20 #define LIBPSPP_FLOAT_FORMAT_H 1
21
22 #include <stdbool.h>
23 #include <stddef.h>
24 #include <libpspp/compiler.h>
25
26 /* A floating-point format. */
27 enum float_format 
28   {
29     /* IEEE 754 formats. */
30     FLOAT_IEEE_SINGLE_LE,          /* 32 bit, little endian. */
31     FLOAT_IEEE_SINGLE_BE,          /* 32 bit, big endian. */
32     FLOAT_IEEE_DOUBLE_LE,          /* 64 bit, little endian. */
33     FLOAT_IEEE_DOUBLE_BE,          /* 64 bit, big endian. */
34
35     /* VAX formats. */
36     FLOAT_VAX_F,                   /* 32 bit VAX F format. */
37     FLOAT_VAX_D,                   /* 64 bit VAX D format. */
38     FLOAT_VAX_G,                   /* 64 bit VAX G format. */
39
40     /* IBM z architecture (390) hexadecimal formats. */
41     FLOAT_Z_SHORT,                 /* 32 bit format. */
42     FLOAT_Z_LONG,                  /* 64 bit format. */
43
44     /* Formats useful for testing. */
45     FLOAT_FP,                      /* Neutral intermediate format. */
46     FLOAT_HEX,                     /* C99 hexadecimal floating constant. */
47
48 #ifdef FPREP_IEEE754
49 #ifdef WORDS_BIGENDIAN
50     FLOAT_NATIVE_FLOAT = FLOAT_IEEE_SINGLE_BE,
51     FLOAT_NATIVE_DOUBLE = FLOAT_IEEE_DOUBLE_BE
52     FLOAT_NATIVE_32_BIT = FLOAT_IEEE_SINGLE_BE,
53     FLOAT_NATIVE_64_BIT = FLOAT_IEEE_DOUBLE_BE
54 #else
55     FLOAT_NATIVE_FLOAT = FLOAT_IEEE_SINGLE_LE,
56     FLOAT_NATIVE_DOUBLE = FLOAT_IEEE_DOUBLE_LE,
57     FLOAT_NATIVE_32_BIT = FLOAT_IEEE_SINGLE_LE,
58     FLOAT_NATIVE_64_BIT = FLOAT_IEEE_DOUBLE_LE
59 #endif
60 #else
61 #error Only IEEE-754 floating point currently supported for PSPP hosts.
62 #endif
63   };
64
65 void float_convert (enum float_format, const void *,
66                     enum float_format, void *);
67
68 double float_get_double (enum float_format, const void *);
69
70 size_t float_get_size (enum float_format) PURE_FUNCTION;
71
72 int float_identify (double expected_value, const void *, size_t,
73                     enum float_format *best_guess);
74
75 #endif /* float-format.h */