Added spec:commit task to commit changes to spec/ruby sources.
[rbx.git] / shotgun / lib / bignum.h
blob5855a0622ab64405b2d1a917bcf3934ed40a1da7
1 #ifndef RBS_BIGNUM_H
2 #define RBS_BIGNUM_H
3 #include <tommath.h>
5 void bignum_debug(STATE, OBJECT n);
6 OBJECT bignum_new(STATE, native_int num);
7 OBJECT bignum_new_unsigned(STATE, unsigned int num);
8 OBJECT bignum_add(STATE, OBJECT a, OBJECT b);
9 OBJECT bignum_sub(STATE, OBJECT a, OBJECT b);
10 OBJECT bignum_mul(STATE, OBJECT a, OBJECT b);
11 OBJECT bignum_div(STATE, OBJECT a, OBJECT b, mp_int *mod);
12 OBJECT bignum_mod(STATE, OBJECT a, OBJECT b);
13 OBJECT bignum_equal(STATE, OBJECT a, OBJECT b);
14 OBJECT bignum_compare(STATE, OBJECT a, OBJECT b);
15 OBJECT bignum_gt(STATE, OBJECT a, OBJECT b);
16 OBJECT bignum_ge(STATE, OBJECT a, OBJECT b);
17 OBJECT bignum_lt(STATE, OBJECT a, OBJECT b);
18 OBJECT bignum_le(STATE, OBJECT a, OBJECT b);
19 OBJECT bignum_and(STATE, OBJECT a, OBJECT b);
20 OBJECT bignum_or(STATE, OBJECT a, OBJECT b);
21 OBJECT bignum_xor(STATE, OBJECT a, OBJECT b);
22 OBJECT bignum_neg(STATE, OBJECT self);
23 OBJECT bignum_invert(STATE, OBJECT self);
24 unsigned long bignum_to_int(STATE, OBJECT self);
25 OBJECT bignum_to_s(STATE, OBJECT self, OBJECT radix);
26 void bignum_into_string(STATE, OBJECT self, int radix, char *buf, int sz);
27 OBJECT bignum_from_string(STATE, char *str, int radix);
28 OBJECT bignum_from_string_detect(STATE, char *str);
29 double bignum_to_double(STATE, OBJECT self);
30 OBJECT bignum_from_double(STATE, double d);
31 OBJECT bignum_left_shift(STATE, OBJECT self, OBJECT bits);
32 OBJECT bignum_right_shift(STATE, OBJECT self, OBJECT bits);
33 OBJECT bignum_divmod(STATE, OBJECT a, OBJECT b);
34 unsigned long long bignum_to_ull(STATE, OBJECT self);
35 long long bignum_to_ll(STATE, OBJECT self);
36 OBJECT bignum_from_ull(STATE, unsigned long long val);
37 OBJECT bignum_from_ll(STATE, long long val);
38 OBJECT bignum_size(STATE, OBJECT self);
39 int bignum_is_zero(STATE, OBJECT a);
40 int bignum_hash_int(OBJECT a);
41 unsigned int bignum_to_ui(STATE, OBJECT self);
42 int bignum_to_i(STATE, OBJECT self);
44 /* initialize and set a long integer value */
45 int mp_init_set_long (mp_int * a, unsigned long b);
46 int mp_set_long (mp_int * a, unsigned long b);
48 /* Workaround for Solaris' bug in math.h */
50 #if defined (__SVR4) && defined (__sun)
51 #undef HUGE_VAL
52 #define HUGE_VAL (1.0/0.0)
53 #endif
55 #endif