Values.h
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003  * 
00004  * Copyright (c) 2012 
00005  * 
00006  * SCHUNK GmbH & Co. KG
00007  *  
00008  * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
00009  * 
00010  * Project name: Drivers for "Amtec M5 Protocol" Electronics V4
00011  *                                                                        
00012  * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
00013  * 
00014  * Email:robotics@schunk.com
00015  * 
00016  * ToDo: 
00017  * 
00018  * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
00019  * 
00020  * Redistribution and use in source and binary forms, with or without 
00021  * modification, are permitted provided that the following conditions are met: 
00022  * 
00023  *  * Redistributions of source code must retain the above copyright 
00024  *    notice, this list of conditions and the following disclaimer. 
00025  *  * Redistributions in binary form must reproduce the above copyright 
00026  *    notice, this list of conditions and the following disclaimer in the 
00027  *    documentation and/or other materials provided with the distribution. 
00028  *  * Neither the name of SCHUNK GmbH & Co. KG nor the names of its 
00029  *    contributors may be used to endorse or promote products derived from 
00030  *    this software without specific prior written permission. 
00031  * 
00032  * This program is free software: you can redistribute it and/or modify 
00033  * it under the terms of the GNU Lesser General Public License LGPL as 
00034  * published by the Free Software Foundation, either version 3 of the 
00035  * License, or (at your option) any later version. 
00036  * 
00037  * This program is distributed in the hope that it will be useful, 
00038  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
00039  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
00040  * GNU Lesser General Public License LGPL for more details. 
00041  * 
00042  * You should have received a copy of the GNU Lesser General Public 
00043  * License LGPL along with this program. 
00044  * If not, see <http://www.gnu.org/licenses/>.
00045  * 
00046  ******************************************************************************/
00047 
00048 
00049 #ifndef UTIL_VALUES_H
00050 #define UTIL_VALUES_H
00051 
00052 // ---- local includes ------------------------------------------------------ ;
00053 
00054 // ---- global includes ----------------------------------------------------- ;
00055 
00056 #if defined(__QNX__) || defined(_WIN32)
00057 
00058 #ifdef _WIN32
00059 #include <winsock2.h>    // prevent include of winsock.h inside windows.h!!
00060 #include <windows.h>
00061 #endif
00062 
00063 #include <limits.h>
00064 #include <float.h>
00065 
00066 #ifdef  __cplusplus
00067 extern "C" {
00068 #endif
00069 
00070 /*
00071  * These values work with any binary representation of integers
00072  * where the high-order bit contains the sign.
00073  */
00074 
00075 /* a number used normally for size of a shift */
00076 #define BITSPERBYTE     8
00077 
00078 #define BITS(type)      (BITSPERBYTE * (int)sizeof (type))
00079 
00080 /* short, regular and long ints with only the high-order bit turned on */
00081 #define HIBITS  ((short)(1 << BITS(short) - 1))
00082 
00083 #if defined(__STDC__)
00084 
00085 #define HIBITI  (1U << BITS(int) - 1)
00086 #define HIBITL  (1UL << BITS(long) - 1)
00087 
00088 #else
00089 
00090 #define HIBITI  ((unsigned)1 << BITS(int) - 1)
00091 #define HIBITL  (1L << BITS(long) - 1)
00092 
00093 #endif
00094 
00095 
00096 #undef MAXINT
00097 #define MAXINT    INT_MAX
00098 
00099 #ifndef _WIN32_WINNT
00100 
00101 #undef MAXSHORT
00102 #undef MAXLONG
00103 
00104 #define MAXSHORT  SHRT_MAX    /* see <limits.h> */
00105 #define MAXLONG   LONG_MAX
00106 
00107 #endif
00108 
00109 /*
00110  * various values that describe the binary floating-point representation
00111  * _EXPBASE     - the exponent base
00112  * DMAXEXP      - the maximum exponent of a double (as returned by frexp())
00113  * FMAXEXP      - the maximum exponent of a float  (as returned by frexp())
00114  * DMINEXP      - the minimum exponent of a double (as returned by frexp())
00115  * FMINEXP      - the minimum exponent of a float  (as returned by frexp())
00116  * MAXDOUBLE    - the largest double
00117  *                      ((_EXPBASE ** DMAXEXP) * (1 - (_EXPBASE ** -DSIGNIF)))
00118  * MAXFLOAT     - the largest float
00119  *                      ((_EXPBASE ** FMAXEXP) * (1 - (_EXPBASE ** -FSIGNIF)))
00120  * MINDOUBLE    - the smallest double (_EXPBASE ** (DMINEXP - 1))
00121  * MINFLOAT     - the smallest float (_EXPBASE ** (FMINEXP - 1))
00122  * DSIGNIF      - the number of significant bits in a double
00123  * FSIGNIF      - the number of significant bits in a float
00124  * DMAXPOWTWO   - the largest power of two exactly representable as a double
00125  * FMAXPOWTWO   - the largest power of two exactly representable as a float
00126  * _IEEE        - 1 if IEEE standard representation is used
00127  * _DEXPLEN     - the number of bits for the exponent of a double
00128  * _FEXPLEN     - the number of bits for the exponent of a float
00129  * _HIDDENBIT   - 1 if high-significance bit of mantissa is implicit
00130  * LN_MAXDOUBLE - the natural log of the largest double  -- log(MAXDOUBLE)
00131  * LN_MINDOUBLE - the natural log of the smallest double -- log(MINDOUBLE)
00132  * LN_MAXFLOAT  - the natural log of the largest float  -- log(MAXFLOAT)
00133  * LN_MINFLOAT  - the natural log of the smallest float -- log(MINFLOAT)
00134  */
00135 
00136 #undef MAXDOUBLE
00137 #undef MINDOUBLE
00138 #undef MAXFLOAT
00139 #undef MINFLOAT
00140 
00141 #define MAXDOUBLE       DBL_MAX     /* see <float.h> */
00142 #define MINDOUBLE       DBL_MIN
00143 #define MAXFLOAT        FLT_MAX
00144 #define MINFLOAT        FLT_MIN
00145 #define _IEEE           1
00146 #define _DEXPLEN        11
00147 #define _HIDDENBIT      1
00148 #define _LENBASE        1
00149 #define DMINEXP (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
00150 #define FMINEXP (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
00151 
00152 #define _EXPBASE        (1 << _LENBASE)
00153 #define _FEXPLEN        8
00154 #define DSIGNIF (BITS(double) - _DEXPLEN + _HIDDENBIT - 1)
00155 #define FSIGNIF (BITS(float)  - _FEXPLEN + _HIDDENBIT - 1)
00156 #define DMAXPOWTWO      ((double)(1L << BITS(long) - 2) * \
00157                                 (1L << DSIGNIF - BITS(long) + 1))
00158 #define FMAXPOWTWO      ((float)(1L << FSIGNIF - 1))
00159 #define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE)
00160 #define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE)
00161 #define LN_MAXDOUBLE    (M_LN2 * DMAXEXP)
00162 #define LN_MAXFLOAT     (float)(M_LN2 * FMAXEXP)
00163 #define LN_MINDOUBLE    (M_LN2 * (DMINEXP - 1))
00164 #define LN_MINFLOAT     (float)(M_LN2 * (FMINEXP - 1))
00165 #define H_PREC  (DSIGNIF % 2 ? (1L << DSIGNIF/2) * M_SQRT2 : 1L << DSIGNIF/2)
00166 #define FH_PREC \
00167         (float)(FSIGNIF % 2 ? (1L << FSIGNIF/2) * M_SQRT2 : 1L << FSIGNIF/2)
00168 #define X_EPS   (1.0/H_PREC)
00169 #define FX_EPS  (float)((float)1.0/FH_PREC)
00170 #define X_PLOSS ((double)(long)(M_PI * H_PREC))
00171 #define FX_PLOSS ((float)(long)(M_PI * FH_PREC))
00172 #define X_TLOSS (M_PI * DMAXPOWTWO)
00173 #define FX_TLOSS (float)(M_PI * FMAXPOWTWO)
00174 #define M_LN2   0.69314718055994530942
00175 #define M_PI    3.14159265358979323846
00176 #define M_SQRT2 1.41421356237309504880
00177 #define MAXBEXP DMAXEXP /* for backward compatibility */
00178 #define MINBEXP DMINEXP /* for backward compatibility */
00179 #define MAXPOWTWO       DMAXPOWTWO /* for backward compatibility */
00180 
00181 #ifdef  __cplusplus
00182 }
00183 #endif
00184 
00185 #else
00186 #include <values.h>
00187 #endif
00188 
00189 #endif // UTIL_VALUES_H


schunk_libm5api
Author(s): Florian Weisshardt
autogenerated on Thu Aug 27 2015 15:06:52