Main Page
Classes
Files
File List
File Members
src
Util
Values.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012 SCHUNK GmbH & Co. KG
3
* Copyright (c) 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*/
17
18
#ifndef UTIL_VALUES_H
19
#define UTIL_VALUES_H
20
21
// ---- local includes ------------------------------------------------------ ;
22
23
// ---- global includes ----------------------------------------------------- ;
24
25
#if defined(__QNX__) || defined(_WIN32)
26
27
#ifdef _WIN32
28
#include <winsock2.h>
// prevent include of winsock.h inside windows.h!!
29
#include <windows.h>
30
#endif
31
32
#include <limits.h>
33
#include <float.h>
34
35
#ifdef __cplusplus
36
extern
"C"
{
37
#endif
38
39
/*
40
* These values work with any binary representation of integers
41
* where the high-order bit contains the sign.
42
*/
43
44
/* a number used normally for size of a shift */
45
#define BITSPERBYTE 8
46
47
#define BITS(type) (BITSPERBYTE * (int)sizeof (type))
48
49
/* short, regular and long ints with only the high-order bit turned on */
50
#define HIBITS ((short)(1 << BITS(short) - 1))
51
52
#if defined(__STDC__)
53
54
#define HIBITI (1U << BITS(int) - 1)
55
#define HIBITL (1UL << BITS(long) - 1)
56
57
#else
58
59
#define HIBITI ((unsigned)1 << BITS(int) - 1)
60
#define HIBITL (1L << BITS(long) - 1)
61
62
#endif
63
64
65
#undef MAXINT
66
#define MAXINT INT_MAX
67
68
#ifndef _WIN32_WINNT
69
70
#undef MAXSHORT
71
#undef MAXLONG
72
73
#define MAXSHORT SHRT_MAX
/* see <limits.h> */
74
#define MAXLONG LONG_MAX
75
76
#endif
77
78
/*
79
* various values that describe the binary floating-point representation
80
* _EXPBASE - the exponent base
81
* DMAXEXP - the maximum exponent of a double (as returned by frexp())
82
* FMAXEXP - the maximum exponent of a float (as returned by frexp())
83
* DMINEXP - the minimum exponent of a double (as returned by frexp())
84
* FMINEXP - the minimum exponent of a float (as returned by frexp())
85
* MAXDOUBLE - the largest double
86
* ((_EXPBASE ** DMAXEXP) * (1 - (_EXPBASE ** -DSIGNIF)))
87
* MAXFLOAT - the largest float
88
* ((_EXPBASE ** FMAXEXP) * (1 - (_EXPBASE ** -FSIGNIF)))
89
* MINDOUBLE - the smallest double (_EXPBASE ** (DMINEXP - 1))
90
* MINFLOAT - the smallest float (_EXPBASE ** (FMINEXP - 1))
91
* DSIGNIF - the number of significant bits in a double
92
* FSIGNIF - the number of significant bits in a float
93
* DMAXPOWTWO - the largest power of two exactly representable as a double
94
* FMAXPOWTWO - the largest power of two exactly representable as a float
95
* _IEEE - 1 if IEEE standard representation is used
96
* _DEXPLEN - the number of bits for the exponent of a double
97
* _FEXPLEN - the number of bits for the exponent of a float
98
* _HIDDENBIT - 1 if high-significance bit of mantissa is implicit
99
* LN_MAXDOUBLE - the natural log of the largest double -- log(MAXDOUBLE)
100
* LN_MINDOUBLE - the natural log of the smallest double -- log(MINDOUBLE)
101
* LN_MAXFLOAT - the natural log of the largest float -- log(MAXFLOAT)
102
* LN_MINFLOAT - the natural log of the smallest float -- log(MINFLOAT)
103
*/
104
105
#undef MAXDOUBLE
106
#undef MINDOUBLE
107
#undef MAXFLOAT
108
#undef MINFLOAT
109
110
#define MAXDOUBLE DBL_MAX
/* see <float.h> */
111
#define MINDOUBLE DBL_MIN
112
#define MAXFLOAT FLT_MAX
113
#define MINFLOAT FLT_MIN
114
#define _IEEE 1
115
#define _DEXPLEN 11
116
#define _HIDDENBIT 1
117
#define _LENBASE 1
118
#define DMINEXP (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
119
#define FMINEXP (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
120
121
#define _EXPBASE (1 << _LENBASE)
122
#define _FEXPLEN 8
123
#define DSIGNIF (BITS(double) - _DEXPLEN + _HIDDENBIT - 1)
124
#define FSIGNIF (BITS(float) - _FEXPLEN + _HIDDENBIT - 1)
125
#define DMAXPOWTWO ((double)(1L << BITS(long) - 2) * \
126
(1L << DSIGNIF - BITS(long) + 1))
127
#define FMAXPOWTWO ((float)(1L << FSIGNIF - 1))
128
#define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE)
129
#define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE)
130
#define LN_MAXDOUBLE (M_LN2 * DMAXEXP)
131
#define LN_MAXFLOAT (float)(M_LN2 * FMAXEXP)
132
#define LN_MINDOUBLE (M_LN2 * (DMINEXP - 1))
133
#define LN_MINFLOAT (float)(M_LN2 * (FMINEXP - 1))
134
#define H_PREC (DSIGNIF % 2 ? (1L << DSIGNIF/2) * M_SQRT2 : 1L << DSIGNIF/2)
135
#define FH_PREC \
136
(float)(FSIGNIF % 2 ? (1L << FSIGNIF/2) * M_SQRT2 : 1L << FSIGNIF/2)
137
#define X_EPS (1.0/H_PREC)
138
#define FX_EPS (float)((float)1.0/FH_PREC)
139
#define X_PLOSS ((double)(long)(M_PI * H_PREC))
140
#define FX_PLOSS ((float)(long)(M_PI * FH_PREC))
141
#define X_TLOSS (M_PI * DMAXPOWTWO)
142
#define FX_TLOSS (float)(M_PI * FMAXPOWTWO)
143
#define M_LN2 0.69314718055994530942
144
#define M_PI 3.14159265358979323846
145
#define M_SQRT2 1.41421356237309504880
146
#define MAXBEXP DMAXEXP
/* for backward compatibility */
147
#define MINBEXP DMINEXP
/* for backward compatibility */
148
#define MAXPOWTWO DMAXPOWTWO
/* for backward compatibility */
149
150
#ifdef __cplusplus
151
}
152
#endif
153
154
#else
155
#include <values.h>
156
#endif
157
158
#endif // UTIL_VALUES_H
schunk_libm5api
Author(s): Florian Weisshardt
autogenerated on Mon Nov 25 2019 03:48:19