Values.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2012 SCHUNK GmbH & Co. KG
00003  * Copyright (c) 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *   http://www.apache.org/licenses/LICENSE-2.0
00010 
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef UTIL_VALUES_H
00019 #define UTIL_VALUES_H
00020 
00021 // ---- local includes ------------------------------------------------------ ;
00022 
00023 // ---- global includes ----------------------------------------------------- ;
00024 
00025 #if defined(__QNX__) || defined(_WIN32)
00026 
00027 #ifdef _WIN32
00028 #include <winsock2.h>    // prevent include of winsock.h inside windows.h!!
00029 #include <windows.h>
00030 #endif
00031 
00032 #include <limits.h>
00033 #include <float.h>
00034 
00035 #ifdef  __cplusplus
00036 extern "C" {
00037 #endif
00038 
00039 /*
00040  * These values work with any binary representation of integers
00041  * where the high-order bit contains the sign.
00042  */
00043 
00044 /* a number used normally for size of a shift */
00045 #define BITSPERBYTE     8
00046 
00047 #define BITS(type)      (BITSPERBYTE * (int)sizeof (type))
00048 
00049 /* short, regular and long ints with only the high-order bit turned on */
00050 #define HIBITS  ((short)(1 << BITS(short) - 1))
00051 
00052 #if defined(__STDC__)
00053 
00054 #define HIBITI  (1U << BITS(int) - 1)
00055 #define HIBITL  (1UL << BITS(long) - 1)
00056 
00057 #else
00058 
00059 #define HIBITI  ((unsigned)1 << BITS(int) - 1)
00060 #define HIBITL  (1L << BITS(long) - 1)
00061 
00062 #endif
00063 
00064 
00065 #undef MAXINT
00066 #define MAXINT    INT_MAX
00067 
00068 #ifndef _WIN32_WINNT
00069 
00070 #undef MAXSHORT
00071 #undef MAXLONG
00072 
00073 #define MAXSHORT  SHRT_MAX    /* see <limits.h> */
00074 #define MAXLONG   LONG_MAX
00075 
00076 #endif
00077 
00078 /*
00079  * various values that describe the binary floating-point representation
00080  * _EXPBASE     - the exponent base
00081  * DMAXEXP      - the maximum exponent of a double (as returned by frexp())
00082  * FMAXEXP      - the maximum exponent of a float  (as returned by frexp())
00083  * DMINEXP      - the minimum exponent of a double (as returned by frexp())
00084  * FMINEXP      - the minimum exponent of a float  (as returned by frexp())
00085  * MAXDOUBLE    - the largest double
00086  *                      ((_EXPBASE ** DMAXEXP) * (1 - (_EXPBASE ** -DSIGNIF)))
00087  * MAXFLOAT     - the largest float
00088  *                      ((_EXPBASE ** FMAXEXP) * (1 - (_EXPBASE ** -FSIGNIF)))
00089  * MINDOUBLE    - the smallest double (_EXPBASE ** (DMINEXP - 1))
00090  * MINFLOAT     - the smallest float (_EXPBASE ** (FMINEXP - 1))
00091  * DSIGNIF      - the number of significant bits in a double
00092  * FSIGNIF      - the number of significant bits in a float
00093  * DMAXPOWTWO   - the largest power of two exactly representable as a double
00094  * FMAXPOWTWO   - the largest power of two exactly representable as a float
00095  * _IEEE        - 1 if IEEE standard representation is used
00096  * _DEXPLEN     - the number of bits for the exponent of a double
00097  * _FEXPLEN     - the number of bits for the exponent of a float
00098  * _HIDDENBIT   - 1 if high-significance bit of mantissa is implicit
00099  * LN_MAXDOUBLE - the natural log of the largest double  -- log(MAXDOUBLE)
00100  * LN_MINDOUBLE - the natural log of the smallest double -- log(MINDOUBLE)
00101  * LN_MAXFLOAT  - the natural log of the largest float  -- log(MAXFLOAT)
00102  * LN_MINFLOAT  - the natural log of the smallest float -- log(MINFLOAT)
00103  */
00104 
00105 #undef MAXDOUBLE
00106 #undef MINDOUBLE
00107 #undef MAXFLOAT
00108 #undef MINFLOAT
00109 
00110 #define MAXDOUBLE       DBL_MAX     /* see <float.h> */
00111 #define MINDOUBLE       DBL_MIN
00112 #define MAXFLOAT        FLT_MAX
00113 #define MINFLOAT        FLT_MIN
00114 #define _IEEE           1
00115 #define _DEXPLEN        11
00116 #define _HIDDENBIT      1
00117 #define _LENBASE        1
00118 #define DMINEXP (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
00119 #define FMINEXP (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
00120 
00121 #define _EXPBASE        (1 << _LENBASE)
00122 #define _FEXPLEN        8
00123 #define DSIGNIF (BITS(double) - _DEXPLEN + _HIDDENBIT - 1)
00124 #define FSIGNIF (BITS(float)  - _FEXPLEN + _HIDDENBIT - 1)
00125 #define DMAXPOWTWO      ((double)(1L << BITS(long) - 2) * \
00126                                 (1L << DSIGNIF - BITS(long) + 1))
00127 #define FMAXPOWTWO      ((float)(1L << FSIGNIF - 1))
00128 #define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE)
00129 #define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE)
00130 #define LN_MAXDOUBLE    (M_LN2 * DMAXEXP)
00131 #define LN_MAXFLOAT     (float)(M_LN2 * FMAXEXP)
00132 #define LN_MINDOUBLE    (M_LN2 * (DMINEXP - 1))
00133 #define LN_MINFLOAT     (float)(M_LN2 * (FMINEXP - 1))
00134 #define H_PREC  (DSIGNIF % 2 ? (1L << DSIGNIF/2) * M_SQRT2 : 1L << DSIGNIF/2)
00135 #define FH_PREC \
00136         (float)(FSIGNIF % 2 ? (1L << FSIGNIF/2) * M_SQRT2 : 1L << FSIGNIF/2)
00137 #define X_EPS   (1.0/H_PREC)
00138 #define FX_EPS  (float)((float)1.0/FH_PREC)
00139 #define X_PLOSS ((double)(long)(M_PI * H_PREC))
00140 #define FX_PLOSS ((float)(long)(M_PI * FH_PREC))
00141 #define X_TLOSS (M_PI * DMAXPOWTWO)
00142 #define FX_TLOSS (float)(M_PI * FMAXPOWTWO)
00143 #define M_LN2   0.69314718055994530942
00144 #define M_PI    3.14159265358979323846
00145 #define M_SQRT2 1.41421356237309504880
00146 #define MAXBEXP DMAXEXP /* for backward compatibility */
00147 #define MINBEXP DMINEXP /* for backward compatibility */
00148 #define MAXPOWTWO       DMAXPOWTWO /* for backward compatibility */
00149 
00150 #ifdef  __cplusplus
00151 }
00152 #endif
00153 
00154 #else
00155 #include <values.h>
00156 #endif
00157 
00158 #endif // UTIL_VALUES_H


schunk_libm5api
Author(s): Florian Weisshardt
autogenerated on Sat Jun 8 2019 20:25:13