DGtal  0.9.2
NumberTraits.ih
1 /**
2  * This program is free software: you can redistribute it and/or modify
3  * it under the terms of the GNU Lesser General Public License as
4  * published by the Free Software Foundation, either version 3 of the
5  * License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program. If not, see <http://www.gnu.org/licenses/>.
14  *
15  **/
16 
17 /**
18  * @file NumberTraits.ih
19  * @author Jacques-Olivier Lachaud (\c jacques-olivier.lachaud@univ-savoie.fr )
20  * Laboratory of Mathematics (CNRS, UMR 5807), University of Savoie, France
21  *
22  * @date 2010/07/03
23  *
24  * Implementation of inline methods defined in NumberTraits.h
25  *
26  * This file is part of the DGtal library.
27  */
28 
29 
30 //////////////////////////////////////////////////////////////////////////////
31 #include <cstdlib>
32 #include <limits>
33 //////////////////////////////////////////////////////////////////////////////
34 
35 ///////////////////////////////////////////////////////////////////////////////
36 // IMPLEMENTATION of inline methods.
37 ///////////////////////////////////////////////////////////////////////////////
38 
39 ///////////////////////////////////////////////////////////////////////////////
40 // ----------------------- Standard services ------------------------------
41 
42 
43 /**
44  * @return the zero of this integer.
45  */
46 template <typename T>
47 inline
48 typename DGtal::NumberTraits<T>::ReturnType
49 DGtal::NumberTraits<T>::zero()
50 {
51 #if (defined(WIN32))
52  return 0;
53 #else
54  return ZERO;
55 #endif
56 }
57 
58 /**
59  * @return the one of this integer.
60  */
61 template <typename T>
62 inline
63 typename DGtal::NumberTraits<T>::ReturnType
64 DGtal::NumberTraits<T>::one()
65 {
66 #if (defined(WIN32))
67  return 1;
68 #else
69  return ONE;
70 #endif
71 }
72 
73 /**
74  * @return the minimum possible value for this type of integer or
75  * ONE if not bounded or unknown.
76  */
77 template <typename T>
78 inline
79 typename DGtal::NumberTraits<T>::ReturnType
80 DGtal::NumberTraits<T>::min()
81 {
82  return ONE;
83 }
84 
85 /**
86  * @return the maximum possible value for this type of integer or
87  * ZERO if not bounded or unknown.
88  */
89 template <typename T>
90 inline
91 typename DGtal::NumberTraits<T>::ReturnType
92 DGtal::NumberTraits<T>::max()
93 {
94  return ZERO;
95 }
96 
97 /**
98  * @return the number of significant digits for this integer type,
99  * or 0 if unbounded or unknown.
100  */
101 template <typename T>
102 inline
103 unsigned int
104 DGtal::NumberTraits<T>::digits()
105 {
106  return 0;
107 }
108 
109 /**
110  * @return 1 if bounded, 0, if not bounded, 2 if unknown.
111  */
112 template <typename T>
113 inline
114 DGtal::BoundEnum
115 DGtal::NumberTraits<T>::isBounded()
116 {
117  return BOUND_UNKNOWN;
118 }
119 
120 /**
121  * @return 1 if unsigned, 0, if signed, 2 if unknown.
122  */
123 template <typename T>
124 inline
125 DGtal::SignEnum
126 DGtal::NumberTraits<T>::isSigned()
127 {
128  return SIGN_UNKNOWN;
129 }
130 
131 ///////////////////////////////////////////////////////////////////////////////