27139af9a88feed090bf58440f3d520d28e00703
[pspp-builds.git] / src / data / val-type.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 2007 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 3 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 DATA_VAL_TYPE_H
20 #define DATA_VAL_TYPE_H 1
21
22 #include <float.h>
23 #include <stdbool.h>
24 #include <libpspp/float-format.h>
25
26 /* Special numeric values. */
27 #define SYSMIS (-DBL_MAX)               /* System-missing value. */
28 #define LOWEST (float_get_lowest ())    /* Smallest nonmissing finite value. */
29 #define HIGHEST DBL_MAX                 /* Largest finite value. */
30
31 /* Maximum length of a string variable. */
32 #define MAX_STRING 32767
33
34 /* Value type. */
35 enum val_type
36   {
37     VAL_NUMERIC,              /* A numeric value. */
38     VAL_STRING                /* A string value. */
39   };
40
41 /* Returns true if VAL_TYPE is a valid value type. */
42 static inline bool
43 val_type_is_valid (enum val_type val_type)
44 {
45   return val_type == VAL_NUMERIC || val_type == VAL_STRING;
46 }
47
48 /* Returns the value type for the given WIDTH. */
49 static inline enum val_type
50 val_type_from_width (int width)
51 {
52   return width != 0 ? VAL_STRING : VAL_NUMERIC;
53 }
54
55 #endif /* data/val-type.h */