SpeedCrunch  0.11
/usr/src/RPM/BUILD/speedcrunch-0.11/src/math/floatconvert.h
Go to the documentation of this file.
00001 /* floatconvert.h: radix conversion, based on floatnum. */
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 #ifndef FLOATCONVERT_H
00033 # define FLOATCONVERT_H
00034 
00035 #include "floatnum.h"
00036 #include "floatlong.h"
00037 
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041 
00042 #define IO_MODE_SCIENTIFIC 0
00043 #define IO_MODE_FIXPOINT   1
00044 #define IO_MODE_ENG        2
00045 #define IO_MODE_COMPLEMENT 3
00046 
00047 /* converts the integer part of f to a binary coded bigint. Returns
00048    IOConversionOverflow, if the bigint overflows */
00049 Error _floatnum2longint(t_longint* longint, floatnum f);
00050 /* converts a binary coded bigint into a floatnum */
00051 void _longint2floatnum(floatnum f, t_longint* longint);
00052 
00053 /* the output process destroys x
00054    'digits' are the number of digits after the dot.
00055    Regardless of the value of 'digits', a conversion is always
00056    done to DECPRECISION places
00057    Before reducing to 'digits' places the (converted) value is rounded.
00058    Trailing zeros are padded, if necessary, to fill to the right size.
00059    Errors: InvalidParam (if any of the parameters makes no sense
00060                          like digits <= 0, or a not supported base)
00061            IOBufferOverflow (if the caller does not provide enough
00062                              buffer in tokens)
00063            IOConversionOverflow (request requires too much buffer
00064                                  space for radix conversion)
00065            IOConversionUnderflow (request would produce leading
00066                                   zeros only)
00067            IOInvalidComplement (two's complement cannot be generated) */
00068 Error float_out(p_otokens tokens, floatnum x, int digits,
00069                 signed char base, char outmode);
00070 /* returns Success or one of the IO... codes
00071    Errors: BadLiteral, set in addition to the returned result */
00072 Error float_in(floatnum x, p_itokens tokens);
00073 
00074 #ifdef __cplusplus
00075 }
00076 #endif
00077 
00078 #endif /* FLOATCONVERT_H */