File indexing completed on 2024-05-12 05:55:14

0001 /* floatlong.h: portable double size integer arithmetic */
0002 /*
0003     Copyright (C) 2007, 2008 Wolf Lammen.
0004 
0005     This program is free software; you can redistribute it and/or modify
0006     it under the terms of the GNU General Public License as published by
0007     the Free Software Foundation; either version 2 of the License , or
0008     (at your option) any later version.
0009 
0010     This program is distributed in the hope that it will be useful,
0011     but WITHOUT ANY WARRANTY; without even the implied warranty of
0012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013     GNU General Public License for more details.
0014 
0015     You should have received a copy of the GNU General Public License
0016     along with this program; see the file COPYING.  If not, write to:
0017 
0018       The Free Software Foundation, Inc.
0019       59 Temple Place, Suite 330
0020       Boston, MA 02111-1307 USA.
0021 
0022 
0023     You may contact the author by:
0024        e-mail:  ookami1 <at> gmx <dot> de
0025        mail:  Wolf Lammen
0026               Oertzweg 45
0027               22307 Hamburg
0028               Germany
0029 
0030 *************************************************************************/
0031 
0032 
0033 #ifndef FLOATLONG_H
0034 # define FLOATLONG_H
0035 
0036 #include "floatconfig.h"
0037 
0038 #ifdef __cplusplus
0039 extern "C" {
0040 #endif
0041 
0042 #define BITS_IN_UNSIGNED (sizeof(unsigned)*8)
0043 
0044 /* one unsigned extra, so that _bitsubstr() does not access parts
0045    outside of t_uarray */
0046 #define UARRAYLG ((8305*(MATHPRECISION+5) + 1)/20000/sizeof(unsigned) + 2)
0047 
0048 typedef unsigned t_uarray[UARRAYLG];
0049 
0050 typedef struct{
0051   int length;
0052   t_uarray value;
0053 } t_longint;
0054 
0055 int _findfirstbit(unsigned value);
0056 char _longadd(unsigned* s1, unsigned* s2);
0057 char _longmul(unsigned* f1, unsigned* f2);
0058 char _checkadd(int* s1, int s2);
0059 char _checkmul(int* f1, int f2);
0060 unsigned _longshr(unsigned low, unsigned high, char shift);
0061 unsigned _longshl(unsigned low, unsigned high, char shift);
0062 unsigned _longarrayadd(unsigned* uarray, int lg, unsigned incr);
0063 unsigned _longarraymul(unsigned* uarray, int lg, unsigned factor);
0064 void _orsubstr(unsigned* uarray, int bitofs, unsigned value);
0065 unsigned _bitsubstr(unsigned* uarray, int ofs);
0066 unsigned _bitlength(t_longint* l);
0067 unsigned _lastnonzerobit(t_longint* l);
0068 char _longintsetsize(t_longint* l, unsigned bitlength);
0069 unsigned _longintadd(t_longint* l, unsigned summand);
0070 unsigned _longintmul(t_longint* l, unsigned factor);
0071 
0072 #ifdef __cplusplus
0073 }
0074 #endif
0075 
0076 #endif /* FLOATLONG_H */