mac_drand48r.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2011 LpzRobots development team                    *
00003  *    Georg Martius  <georg dot martius at web dot de>                     *
00004  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
00005  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
00006  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
00007  *                                                                         *
00008  *   This program is free software; you can redistribute it and/or modify  *
00009  *   it under the terms of the GNU General Public License as published by  *
00010  *   the Free Software Foundation; either version 2 of the License, or     *
00011  *   (at your option) any later version.                                   *
00012  *                                                                         *
00013  *   This program is distributed in the hope that it will be useful,       *
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00016  *   GNU General Public License for more details.                          *
00017  *                                                                         *
00018  *   You should have received a copy of the GNU General Public License     *
00019  *   along with this program; if not, write to the                         *
00020  *   Free Software Foundation, Inc.,                                       *
00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00022  *                                                                         *
00023  ***************************************************************************/
00024 #ifndef __MACDRAND48_R_H
00025 #define __MACDRAND48_R_H
00026 
00027 #include <stdlib.h>
00028 
00029 #include <limits.h>
00030 #ifndef WIN32
00031 #include <mach/mach.h>
00032 #endif
00033 
00034 union ieee754_double
00035   {
00036     double d;
00037 
00038     /* This is the IEEE 754 double-precision format.  */
00039     struct
00040       {
00041         /* Together these comprise the mantissa.  */
00042         unsigned int mantissa1:32;
00043         unsigned int mantissa0:20;
00044         unsigned int exponent:11;
00045         unsigned int negative:1;
00046       } ieee;
00047 
00048     /* This format makes it easier to see if a NaN is a signalling NaN.  */
00049     struct
00050       {
00051         /* Together these comprise the mantissa.  */
00052         unsigned int mantissa1:32;
00053         unsigned int mantissa0:19;
00054         unsigned int quiet_nan:1;
00055         unsigned int exponent:11;
00056         unsigned int negative:1;
00057       } ieee_nan;
00058   };
00059 
00060 #define IEEE754_DOUBLE_BIAS     0x3ff /* Added to exponent.  */
00061 
00062 
00063 struct drand48_data {
00064   unsigned short int __x[3];    /* Current state.  */
00065   unsigned short int __old_x[3]; /* Old state.  */
00066   unsigned short int __c;       /* Additive const. in congruential formula.  */
00067   unsigned short int __init;    /* Flag for initializing.  */
00068   unsigned long long int __a;   /* Factor in congruential formula.  */
00069 };
00070 
00071 
00072 int srand48_r (long int seedval, struct drand48_data *buffer);
00073 
00074 int drand48_r ( struct drand48_data *buffer, double *result);
00075 
00076 
00077 #endif
Generated on Thu Jun 28 14:45:36 2012 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.6.3