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(PARROT_INTERP, PMC *self)
static void bignum_clear(PARROT_INTERP, PMC *self)
static void bignum_set(PARROT_INTERP, PMC *dest, PMC *src)
static void bignum_set_si(PARROT_INTERP, PMC *self, long value)
static void bignum_set_ui(PARROT_INTERP, PMC *self, unsigned long value)
static void bignum_set_float(PARROT_INTERP, PMC *self, FLOATVAL value)
static void bignum_set_double(PARROT_INTERP, PMC *self, double value)
static void bignum_set_str(PARROT_INTERP, PMC *self, const char *value, int base)
static void bignum_set_bigint(PARROT_INTERP, PMC *self, struct BIGINT *value)
static BIGNUM* bignum_get_self(PARROT_INTERP, PMC *self)
static void bignum_set_self(PARROT_INTERP, PMC *self, BIGNUM *value)
static long bignum_get_si(PARROT_INTERP, PMC *self)
static unsigned long bignum_get_ui(PARROT_INTERP, PMC *self)
static INTVAL bignum_get_bool(PARROT_INTERP, ARGIN(PMC *self))
static char * bignum_get_string(PARROT_INTERP, PMC *self, int base)
static char * bignum_get_string_size(PARROT_INTERP, PMC *self, int base, int digits)
static double bignum_get_double(PARROT_INTERP, PMC *self)
static FLOATVAL bignum_get_float(PARROT_INTERP, PMC *self)
static BIGINT bignum_get_bigint(Interp*, ARGIN(PMC *self))
static void bignum_add_bignum(PARROT_INTERP, PMC *self, PMC *value, PMC *dest)
static void bignum_add_bignum_int(PARROT_INTERP, PMC *self, INTVAL value, PMC *dest)
static void bignum_add_bignum_float(PARROT_INTERP, PMC *self, FLOATVAL value, PMC *dest)
static void bignum_sub_bignum(PARROT_INTERP, PMC *self, PMC *value, PMC *dest)
static void bignum_sub_bignum_int(PARROT_INTERP, PMC *self, INTVAL value, PMC *dest)
static void bignum_sub_bignum_float(PARROT_INTERP, PMC *self, FLOATVAL value, PMC *dest)
static void bignum_mul_bignum(PARROT_INTERP, PMC *self, PMC *value, PMC *dest)
static void bignum_mul_bignum_int(PARROT_INTERP, PMC *self, INTVAL value, PMC *dest)
static void bignum_mul_bignum_float(PARROT_INTERP, PMC *self, FLOATVAL value, PMC *dest)
static void bignum_pow_bignum_int(PARROT_INTERP, PMC *self, INTVAL value, PMC *dest)
static void bignum_check_divide_zero(Interp*, PMC *value)
static void bignum_div_bignum(PARROT_INTERP, PMC *self, PMC *value, PMC *dest)
static void bignum_div_bignum_int(PARROT_INTERP, PMC *self, INTVAL value, PMC *dest)
static void bignum_div_bignum_float(PARROT_INTERP, PMC *self, FLOATVAL value, PMC *dest)
static void bignum_fdiv_bignum(PARROT_INTERP, PMC *self, PMC *value, PMC *dest)
static void bignum_fdiv_bignum_int(PARROT_INTERP, PMC *self, INTVAL value, PMC *dest)
static INTVAL bignum_cmp(PARROT_INTERP, PMC *self, PMC *value)
static INTVAL bignum_cmp_double(PARROT_INTERP, PMC *self, double value)
static INTVAL bignum_cmp_int(PARROT_INTERP, PMC *self, INTVAL value)
static INTVAL bignum_cmp_ulong(PARROT_INTERP, PMC *self, unsigned long value)
static void bignum_abs(PARROT_INTERP, PMC *self, PMC *dest)
static void bignum_neg(PARROT_INTERP, PMC *self, PMC *dest)
static INTVAL bignum_get_default_prec(PARROT_INTERP, PMC *self)
static void bignum_set_default_prec(PARROT_INTERP, PMC *self, INTVAL prec)
All the above functions are local to the bignum pmc and are there to provide interface functions to The GNU MP Bignum Library (GMP)If GMP is not available, at present these functions will throw a NYI exception.(It would be appreciated if maintainers/implementors could improve the documentation here at some stage. possibly adding documentation for individual functions - at least the less obvious ones.)
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
.