00001 // COCONUT special infinity value -*- C++ -*- 00002 00003 // $Id: vgtl_infinity.h 347 2008-02-06 15:20:01Z schilly $ 00004 // Copyright (C) 2007 Hermann Schichl 00005 // 00006 // This file is part of the COCONUT API. This library 00007 // is free software; you can redistribute it and/or modify it under the 00008 // terms of the Library GNU General Public License as published by the 00009 // Free Software Foundation; either version 2, or (at your option) 00010 // any later version. 00011 00012 // This library is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // Library GNU General Public License for more details. 00016 00017 // As a special exception, you may use this file as part of a free software 00018 // library without restriction. Specifically, if other files instantiate 00019 // templates or use macros or inline functions from this file, or you compile 00020 // this file and link it with other files to produce an executable, this 00021 // file does not by itself cause the resulting executable to be covered by 00022 // the Library GNU General Public License. This exception does not however 00023 // invalidate any other reasons why the executable file might be covered by 00024 // the Library GNU General Public License. 00025 00028 #ifndef ___INFINITY_H__ 00029 #define ___INFINITY_H__ 00030 00031 #include <limits> 00032 00033 #ifndef INFINITY 00034 00035 #if defined(__GNUC__) && __GNUC__ >= 2 00036 #if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC__MINOR >= 96 ) 00037 00038 # define INFINITY (__extension__ 0x1.0p2047) 00039 #else 00040 # ifndef __double_convert_t 00041 # define __double_convert_t union { unsigned char __c[8]; double __d; } 00042 # endif 00043 # define __INFINITY_bytes { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } 00044 00046 # define INFINITY (__extension__ \ 00047 ((__double_convert_t) { __c: __INFINITY_bytes }).__d) 00048 #endif /* GCC > 2.95 */ 00049 # else /* Not GCC. */ 00050 # ifndef __double_convert_t 00051 # define __double_convert_t union { unsigned char __c[8]; double __d; } 00052 # endif 00053 # define __INFINITY_bytes { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } 00054 static __double_convert_t __infinity = { __INFINITY_bytes }; 00056 # define INFINITY (__infinity.__d) 00057 # endif // GCC 00058 #endif // ifdef INFINITY 00059 00061 #define COCO_INF ((double) INFINITY) 00062 00063 #endif /* ___INFINITY_H__ */