SpeedCrunch  0.11
/usr/src/RPM/BUILD/speedcrunch-0.11/src/math/floatlong.h
Go to the documentation of this file.
00001 /* floatlong.h: portable double size integer arithmetic */
00002 /*
00003     Copyright (C) 2007, 2008 Wolf Lammen.
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License , or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; see the file COPYING.  If not, write to:
00017 
00018       The Free Software Foundation, Inc.
00019       59 Temple Place, Suite 330
00020       Boston, MA 02111-1307 USA.
00021 
00022 
00023     You may contact the author by:
00024        e-mail:  ookami1 <at> gmx <dot> de
00025        mail:  Wolf Lammen
00026               Oertzweg 45
00027               22307 Hamburg
00028               Germany
00029 
00030 *************************************************************************/
00031 
00032 
00033 #ifndef FLOATLONG_H
00034 # define FLOATLONG_H
00035 
00036 #include "floatconfig.h"
00037 
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041 
00042 #define BITS_IN_UNSIGNED (sizeof(unsigned)*8)
00043 
00044 /* one unsigned extra, so that _bitsubstr() does not access parts
00045    outside of t_uarray */
00046 #define UARRAYLG ((8305*(MATHPRECISION+5) + 1)/20000/sizeof(unsigned) + 2)
00047 
00048 typedef unsigned t_uarray[UARRAYLG];
00049 
00050 typedef struct{
00051   int length;
00052   t_uarray value;
00053 } t_longint;
00054 
00055 int _findfirstbit(unsigned value);
00056 char _longadd(unsigned* s1, unsigned* s2);
00057 char _longmul(unsigned* f1, unsigned* f2);
00058 char _checkadd(int* s1, int s2);
00059 char _checkmul(int* f1, int f2);
00060 unsigned _longshr(unsigned low, unsigned high, char shift);
00061 unsigned _longshl(unsigned low, unsigned high, char shift);
00062 unsigned _longarrayadd(unsigned* uarray, int lg, unsigned incr);
00063 unsigned _longarraymul(unsigned* uarray, int lg, unsigned factor);
00064 void _orsubstr(unsigned* uarray, int bitofs, unsigned value);
00065 unsigned _bitsubstr(unsigned* uarray, int ofs);
00066 unsigned _bitlength(t_longint* l);
00067 unsigned _lastnonzerobit(t_longint* l);
00068 char _longintsetsize(t_longint* l, unsigned bitlength);
00069 unsigned _longintadd(t_longint* l, unsigned summand);
00070 unsigned _longintmul(t_longint* l, unsigned factor);
00071 
00072 #ifdef __cplusplus
00073 }
00074 #endif
00075 
00076 #endif /* FLOATLONG_H */