1 /* floatlong.h: portable double size integer arithmetic */ 2 /* 3 Copyright (C) 2007, 2008 Wolf Lammen. 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License , or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; see the file COPYING. If not, write to: 17 18 The Free Software Foundation, Inc. 19 59 Temple Place, Suite 330 20 Boston, MA 02111-1307 USA. 21 22 23 You may contact the author by: 24 e-mail: ookami1 <at> gmx <dot> de 25 mail: Wolf Lammen 26 Oertzweg 45 27 22307 Hamburg 28 Germany 29 30 *************************************************************************/ 31 32 33 #ifndef FLOATLONG_H 34 # define FLOATLONG_H 35 36 #include "floatconfig.h" 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 #define BITS_IN_UNSIGNED (sizeof(unsigned)*8) 43 44 /* one unsigned extra, so that _bitsubstr() does not access parts 45 outside of t_uarray */ 46 #define UARRAYLG ((8305*(MATHPRECISION+5) + 1)/20000/sizeof(unsigned) + 2) 47 48 typedef unsigned t_uarray[UARRAYLG]; 49 50 typedef struct{ 51 int length; 52 t_uarray value; 53 } t_longint; 54 55 int _findfirstbit(unsigned value); 56 char _longadd(unsigned* s1, unsigned* s2); 57 char _longmul(unsigned* f1, unsigned* f2); 58 char _checkadd(int* s1, int s2); 59 char _checkmul(int* f1, int f2); 60 unsigned _longshr(unsigned low, unsigned high, char shift); 61 unsigned _longshl(unsigned low, unsigned high, char shift); 62 unsigned _longarrayadd(unsigned* uarray, int lg, unsigned incr); 63 unsigned _longarraymul(unsigned* uarray, int lg, unsigned factor); 64 void _orsubstr(unsigned* uarray, int bitofs, unsigned value); 65 unsigned _bitsubstr(unsigned* uarray, int ofs); 66 unsigned _bitlength(t_longint* l); 67 unsigned _lastnonzerobit(t_longint* l); 68 char _longintsetsize(t_longint* l, unsigned bitlength); 69 unsigned _longintadd(t_longint* l, unsigned summand); 70 unsigned _longintmul(t_longint* l, unsigned factor); 71 72 #ifdef __cplusplus 73 } 74 #endif 75 76 #endif /* FLOATLONG_H */ 77