BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/IEEE_754_unions.h
Go to the documentation of this file.
00001 // Copyright (c) 1999  Utrecht University (The Netherlands),
00002 // ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany),
00003 // INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
00004 // (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria),
00005 // and Tel-Aviv University (Israel).  All rights reserved.
00006 //
00007 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or
00008 // modify it under the terms of the GNU Lesser General Public License as
00009 // published by the Free Software Foundation; version 2.1 of the License.
00010 // See the file LICENSE.LGPL distributed with CGAL.
00011 //
00012 // Licensees holding a valid commercial license may use this file in
00013 // accordance with the commercial license agreement provided with the software.
00014 //
00015 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017 //
00018 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Number_types/include/CGAL/IEEE_754_unions.h $
00019 // $Id: IEEE_754_unions.h 37955 2007-04-05 13:02:19Z spion $
00020 //
00021 //
00022 // Author(s)     : Stefan Schirra
00023 
00024 #ifndef CGAL_IEEE_754_UNIONS_H
00025 #define CGAL_IEEE_754_UNIONS_H
00026 
00027 #include <iomanip>
00028 
00029 union IEEE_754_double
00030 {
00031   double   a;
00032 #ifdef CGAL_BIG_ENDIAN
00033   struct { unsigned sign : 1;
00034            unsigned exp  :11;
00035            unsigned high :20;
00036            unsigned low  :32;
00037          } b;
00038   struct { unsigned H    :32;
00039            unsigned L    :32;
00040          } c;
00041 #else
00042   struct { unsigned low  :32;
00043            unsigned sign : 1;
00044            unsigned exp  :11;
00045            unsigned high :20;
00046          } b;
00047   struct { unsigned L    :32;
00048            unsigned H    :32;
00049          } c;
00050 #endif
00051 };
00052 
00053 union IEEE_754_float
00054 {
00055   float    a;
00056   struct { unsigned sign : 1;
00057            unsigned exp  : 8;
00058            unsigned high :23;
00059          } b;
00060   unsigned c;
00061 };
00062 
00063 inline
00064 void
00065 show( IEEE_754_double* p)
00066 {
00067   std::cout << std::endl;
00068   std::cout << std::hex << std::setw(8) << std::setfill('0') << p->c.H;
00069   std::cout << ' ';
00070   std::cout << std::hex << std::setw(8) << std::setfill('0') << p->c.L;
00071   std::cout << std::endl;
00072 }
00073 
00074 inline
00075 void
00076 show( IEEE_754_float* p)
00077 {
00078   std::cout << std::endl;
00079   std::cout << std::hex << std::setw(8) << std::setfill('0') << p->c;
00080   std::cout << std::endl;
00081 }
00082 
00083 #endif // CGAL_IEEE_754_UNIONS_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines