123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- #ifndef _BCMATH_H_
- #define _BCMATH_H_
- typedef enum {PLUS, MINUS} sign;
- typedef struct bc_struct *bc_num;
- typedef struct bc_struct
- {
- sign n_sign;
- int n_len;
- int n_scale;
- int n_refs;
- char *n_ptr;
- char *n_value;
- } bc_struct;
- #ifdef HAVE_CONFIG_H
- #include "config.h"
- #endif
- #include "php.h"
- #include "../../php_bcmath.h"
- #define BASE 10
- #define CH_VAL(c) (c - '0')
- #define BCD_CHAR(d) (d + '0')
- #ifdef MIN
- #undef MIN
- #undef MAX
- #endif
- #define MAX(a, b) ((a)>(b)?(a):(b))
- #define MIN(a, b) ((a)>(b)?(b):(a))
- #define ODD(a) ((a)&1)
- #ifndef TRUE
- #define TRUE 1
- #define FALSE 0
- #endif
- #ifndef LONG_MAX
- #define LONG_MAX 0x7ffffff
- #endif
- void bc_init_numbers(void);
- bc_num _bc_new_num_ex(int length, int scale, int persistent);
- void _bc_free_num_ex(bc_num *num, int persistent);
- bc_num bc_copy_num(bc_num num);
- void bc_init_num(bc_num *num);
- int bc_str2num(bc_num *num, char *str, int scale);
- zend_string *bc_num2str_ex(bc_num num, int scale);
- void bc_int2num(bc_num *num, int val);
- long bc_num2long(bc_num num);
- int bc_compare(bc_num n1, bc_num n2);
- char bc_is_zero(bc_num num);
- char bc_is_zero_for_scale(bc_num num, int scale);
- char bc_is_near_zero(bc_num num, int scale);
- char bc_is_neg(bc_num num);
- void bc_add(bc_num n1, bc_num n2, bc_num *result, int scale_min);
- void bc_sub(bc_num n1, bc_num n2, bc_num *result, int scale_min);
- void bc_multiply(bc_num n1, bc_num n2, bc_num *prod, int scale);
- int bc_divide(bc_num n1, bc_num n2, bc_num *quot, int scale);
- int bc_modulo(bc_num num1, bc_num num2, bc_num *resul, int scale);
- int bc_divmod(bc_num num1, bc_num num2, bc_num *quo, bc_num *rem, int scale);
- int bc_raisemod(bc_num base, bc_num expo, bc_num mo, bc_num *result, int scale);
- void bc_raise(bc_num num1, bc_num num2, bc_num *resul, int scale);
- int bc_sqrt(bc_num *num, int scale);
- void bc_out_num(bc_num num, int o_base, void (* out_char)(char), int leading_zero);
- #define bc_new_num(length, scale) _bc_new_num_ex((length), (scale), 0)
- #define bc_free_num(num) _bc_free_num_ex((num), 0)
- #define bc_num2str(num) bc_num2str_ex((num), (num->n_scale))
- #endif
|