NAME
src/pmc/bignum.pmc - BigNum PMC class
DESCRIPTION
BigNum provides arbitrary precision floating point mathematic functions,
based on the GMP mpf library.
SYNOPSIS
Make mixing of classes work, like in:
        new $P0 ['BigInt']
        new $P1 ['BigNum']
        set $P0, 10
        set $P1, 2
        div P2, P0, P1  # $P2 = $P0 / $P1; (BigNum) 5.0
Make auto-upgrading/downgrading work.
        set $N1, $P0
        set $N1, $P1
        set $I1, $P0
        set $I1, $P1
        set $P0, $I1
        set $P0, $N1
        set $P1, $I1
        set $P1, $N1
  BigNum
    => BigInt => Integer
    => Number: float (can be long double) and double
    => Integer (unsigned long)
Functions
- static void bignum_init(Interp*, PMC *self)
- static void bignum_clear(Interp*, PMC *self)
- static void bignum_set(Interp*, PMC *dest, PMC *src)
- static void bignum_set_si(Interp*, PMC *self, long value)
- static void bignum_set_ui(Interp*, PMC *self, unsigned long value)
- static void bignum_set_float(Interp*, PMC *self, FLOATVAL value)
- static void bignum_set_double(Interp*, PMC *self, double value)
- static void bignum_set_str(Interp*, PMC *self, char *value, int base)
- static void bignum_set_bigint(Interp*, PMC *self, struct BIGINT *value)
- static BIGNUM* bignum_get_self(Interp*, PMC *self)
- static void bignum_set_self(Interp*, PMC *self, BIGNUM *value)
- static long bignum_get_si(Interp*, PMC *self)
- static unsigned long bignum_get_ui(Interp*, PMC *self)
- static int bignum_get_bool(Interp*, PMC *self)
- static char* bignum_get_string(Interp*, PMC *self, int base)
- static char* bignum_get_string_size(Interp*, PMC *self, int base, int digits)
- static double bignum_get_double(Interp*, PMC *self)
- static FLOATVAL bignum_get_float(Interp*, PMC *self)
- static BIGINT bignum_get_bigint(Interp*, PMC *self)
- static void bignum_add_bignum(Interp*, PMC *self, PMC *value, PMC *dest)
- static void bignum_add_bignum_int(Interp*, PMC *self, INTVAL value, PMC *dest)
- static void bignum_add_bignum_float(Interp*, PMC *self, FLOATVAL value, PMC *dest)
- static void bignum_sub_bignum(Interp*, PMC *self, PMC *value, PMC *dest)
- static void bignum_sub_bignum_int(Interp*, PMC *self, INTVAL value, PMC *dest)
- static void bignum_sub_bignum_float(Interp*, PMC *self, FLOATVAL value, PMC *dest)
- static void bignum_mul_bignum(Interp*, PMC *self, PMC *value, PMC *dest)
- static void bignum_mul_bignum_int(Interp*, PMC *self, INTVAL value, PMC *dest)
- static void bignum_mul_bignum_float(Interp*, PMC *self, FLOATVAL value, PMC *dest)
- static void bignum_pow_bignum_int(Interp*, PMC *self, INTVAL value, PMC *dest)
- static void bignum_check_divide_zero(Interp*, PMC *value)
- static void bignum_div_bignum(Interp*, PMC *self, PMC *value, PMC *dest)
- static void bignum_div_bignum_int(Interp*, PMC *self, INTVAL value, PMC *dest)
- static void bignum_div_bignum_float(Interp*, PMC *self, FLOATVAL value, PMC *dest)
- static void bignum_fdiv_bignum(Interp*, PMC *self, PMC *value, PMC *dest)
- static void bignum_fdiv_bignum_int(Interp*, PMC *self, INTVAL value, PMC *dest)
- static INTVAL bignum_cmp(Interp*, PMC *self, PMC *value)
- static INTVAL bignum_cmp_double(Interp*, PMC *self, double value)
- static INTVAL bignum_cmp_int(Interp*, PMC *self, INTVAL value)
- static INTVAL bignum_cmp_ulong(Interp*, PMC *self, unsigned long value)
- static void bignum_abs(Interp*, PMC *self, PMC *dest)
- static void bignum_neg(Interp*, PMC *self, PMC *dest)
- static INTVAL bignum_get_default_prec(Interp*, PMC *self)
- static void bignum_set_default_prec(Interp*, PMC *self, INTVAL prec)
Methods
- METHOD version()Return GMP version string "x.y.z".
- void set_integer_native(INTVAL value)
- void set_number_native(FLOATVAL value)Sets the value of the BigNum to
- void set_string_native(STRING *value)Sets the value of the BigNum to the result of converting
- void set_string_keyed_int(INTVAL base, STRING *value)Same assume number base
- void set_pmc(PMC *value)Sets the value of the BigNum to the BigNum value of
- FLOATVAL get_number()Down-converts the precise BigNum to an imprecise double.
- INTVAL get_integer()Returns the integer conversion of the BigNum.
- INTVAL get_ulong()Returns the unsigned long conversion of the BigNum.
- FLOATVAL get_bigint()Trunc the BigNum to an BigInt.
- INTVAL get_bool()Returns the boolean value of the BigNum.
- STRING *get_string()Returns the string representation of the BigNum.
- STRING *get_string_keyed_int(INTVAL base)Returns the string representation of the BigNum in base
- STRING *get_string_keyed_int_int(INTVAL base, INTVAL digits)Returns the string representation of the BigNum in base
- STRING *get_repr()Returns the string representation of the BigNum with the letter 'N' appended.
- void increment()Increment the BigNum by 1.0.
- void decrement()Decrement the BigNum by 1.0.
- void add()
- void substract()
- void multiply()
- METHOD PMC *pow()Raises self to the power of value. Replacement method added when the pow() vtable was removedTODO: Needs testing. TODO: Only supports Integer values for now.
- void divide()
- void floor_divide()
- void cmp()
- void is_equal()
- PMC *absolute(PMC *dest)
- void i_absolute()Sets
- PMC *neg(PMC *dest)
- void i_neg()Set
value.
*value to a number.
base.
*value.
base.
base with digits digits.
dest to the absolute value of SELF.
dest to the negated value of SELF.