File indexing completed on 2024-05-12 17:22:32
0001 /* floatconvert.h: radix conversion, based on floatnum. */ 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 #ifndef FLOATCONVERT_H 0033 # define FLOATCONVERT_H 0034 0035 #include "floatnum.h" 0036 #include "floatlong.h" 0037 0038 #ifdef __cplusplus 0039 extern "C" { 0040 #endif 0041 0042 #define IO_MODE_SCIENTIFIC 0 0043 #define IO_MODE_FIXPOINT 1 0044 #define IO_MODE_ENG 2 0045 #define IO_MODE_COMPLEMENT 3 0046 0047 /* converts the integer part of f to a binary coded bigint. Returns 0048 IOConversionOverflow, if the bigint overflows */ 0049 Error _floatnum2longint(t_longint* longint, floatnum f); 0050 /* converts a binary coded bigint into a floatnum */ 0051 void _longint2floatnum(floatnum f, t_longint* longint); 0052 0053 /* the output process destroys x 0054 'digits' are the number of digits after the dot. 0055 Regardless of the value of 'digits', a conversion is always 0056 done to DECPRECISION places 0057 Before reducing to 'digits' places the (converted) value is rounded. 0058 Trailing zeros are padded, if necessary, to fill to the right size. 0059 Errors: InvalidParam (if any of the parameters makes no sense 0060 like digits <= 0, or a not supported base) 0061 IOBufferOverflow (if the caller does not provide enough 0062 buffer in tokens) 0063 IOConversionOverflow (request requires too much buffer 0064 space for radix conversion) 0065 IOConversionUnderflow (request would produce leading 0066 zeros only) 0067 IOInvalidComplement (two's complement cannot be generated) */ 0068 Error float_out(p_otokens tokens, floatnum x, int digits, 0069 signed char base, char outmode); 0070 /* returns Success or one of the IO... codes 0071 Errors: BadLiteral, set in addition to the returned result */ 0072 Error float_in(floatnum x, p_itokens tokens); 0073 0074 #ifdef __cplusplus 0075 } 0076 #endif 0077 0078 #endif /* FLOATCONVERT_H */