Update all #include directives to the currently preferred style.
[pspp-builds.git] / src / libpspp / float-format.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 2006, 2011 Free Software Foundation, Inc.
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU 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, see <http://www.gnu.org/licenses/>. */
16
17 #ifndef LIBPSPP_FLOAT_FORMAT_H
18 #define LIBPSPP_FLOAT_FORMAT_H 1
19
20 #include <stdbool.h>
21 #include <stddef.h>
22 #include "libpspp/compiler.h"
23
24 /* A floating-point format. */
25 enum float_format
26   {
27     /* IEEE 754 formats. */
28     FLOAT_IEEE_SINGLE_LE,          /* 32 bit, little endian. */
29     FLOAT_IEEE_SINGLE_BE,          /* 32 bit, big endian. */
30     FLOAT_IEEE_DOUBLE_LE,          /* 64 bit, little endian. */
31     FLOAT_IEEE_DOUBLE_BE,          /* 64 bit, big endian. */
32
33     /* VAX formats. */
34     FLOAT_VAX_F,                   /* 32 bit VAX F format. */
35     FLOAT_VAX_D,                   /* 64 bit VAX D format. */
36     FLOAT_VAX_G,                   /* 64 bit VAX G format. */
37
38     /* IBM z architecture (390) hexadecimal formats. */
39     FLOAT_Z_SHORT,                 /* 32 bit format. */
40     FLOAT_Z_LONG,                  /* 64 bit format. */
41
42     /* Formats useful for testing. */
43     FLOAT_FP,                      /* Neutral intermediate format. */
44     FLOAT_HEX,                     /* C99 hexadecimal floating constant. */
45
46 #ifdef WORDS_BIGENDIAN
47     FLOAT_NATIVE_FLOAT = FLOAT_IEEE_SINGLE_BE,
48     FLOAT_NATIVE_DOUBLE = FLOAT_IEEE_DOUBLE_BE,
49     FLOAT_NATIVE_32_BIT = FLOAT_IEEE_SINGLE_BE,
50     FLOAT_NATIVE_64_BIT = FLOAT_IEEE_DOUBLE_BE
51 #else
52     FLOAT_NATIVE_FLOAT = FLOAT_IEEE_SINGLE_LE,
53     FLOAT_NATIVE_DOUBLE = FLOAT_IEEE_DOUBLE_LE,
54     FLOAT_NATIVE_32_BIT = FLOAT_IEEE_SINGLE_LE,
55     FLOAT_NATIVE_64_BIT = FLOAT_IEEE_DOUBLE_LE
56 #endif
57   };
58
59 void float_convert (enum float_format, const void *,
60                     enum float_format, void *);
61
62 double float_get_double (enum float_format, const void *);
63
64 size_t float_get_size (enum float_format) PURE_FUNCTION;
65
66 int float_identify (double expected_value, const void *, size_t,
67                     enum float_format *best_guess);
68
69 double float_get_lowest (void);
70
71 #endif /* float-format.h */