OpenCOBOL 1.1pre-rel
|
00001 /* 00002 * Copyright (C) 2002-2009 Keisuke Nishida 00003 * Copyright (C) 2007-2009 Roger While 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public License 00007 * as published by the Free Software Foundation; either version 2.1, 00008 * or (at your option) any later version. 00009 * 00010 * This library 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 Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; see the file COPYING.LIB. If 00017 * not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor 00018 * Boston, MA 02110-1301 USA 00019 */ 00020 00021 #ifndef COB_NUMERIC_H 00022 #define COB_NUMERIC_H 00023 00024 #include <gmp.h> 00025 #include <libcob/common.h> 00026 00027 #define COB_STORE_ROUND 0x01 00028 #define COB_STORE_KEEP_ON_OVERFLOW 0x02 00029 #define COB_STORE_TRUNC_ON_OVERFLOW 0x04 00030 00031 /* 00032 * Internal representation of decimal numbers. 00033 * 00034 * n = value / 10^scale 00035 */ 00036 typedef struct { 00037 mpz_t value; 00038 int scale; 00039 } cob_decimal; 00040 00041 extern void cob_decimal_init (cob_decimal *); 00042 extern void cob_decimal_set_field (cob_decimal *, cob_field *); 00043 extern int cob_decimal_get_field (cob_decimal *, cob_field *, const int); 00044 extern void cob_decimal_add (cob_decimal *, cob_decimal *); 00045 extern void cob_decimal_sub (cob_decimal *, cob_decimal *); 00046 extern void cob_decimal_mul (cob_decimal *, cob_decimal *); 00047 extern void cob_decimal_div (cob_decimal *, cob_decimal *); 00048 extern void cob_decimal_pow (cob_decimal *, cob_decimal *); 00049 extern int cob_decimal_cmp (cob_decimal *, cob_decimal *); 00050 00051 extern int cob_add (cob_field *, cob_field *, const int); 00052 extern int cob_sub (cob_field *, cob_field *, const int); 00053 extern int cob_add_int (cob_field *, const int); 00054 extern int cob_sub_int (cob_field *, const int); 00055 extern int cob_div_quotient (cob_field *, cob_field *, 00056 cob_field *, const int); 00057 extern int cob_div_remainder (cob_field *, const int); 00058 00059 extern int cob_cmp_int (cob_field *, const int); 00060 extern int cob_cmp_uint (cob_field *, const unsigned int); 00061 extern int cob_cmp_packed (cob_field *, int); 00062 extern int cob_cmp_numdisp (const unsigned char *, 00063 const size_t, const int); 00064 extern int cob_cmp_sign_numdisp (const unsigned char *, 00065 const size_t, const int); 00066 extern int cob_cmp_long_numdisp (const unsigned char *, 00067 const size_t, const int); 00068 extern void cob_set_packed_zero (cob_field *); 00069 extern void cob_set_packed_int (cob_field *, const int); 00070 00071 extern int cob_cmp_long_sign_numdisp (const unsigned char *, 00072 const size_t, const int); 00073 00074 #endif /* COB_NUMERIC_H */