NAME ^

src/classes/integer.pmc - Integer PMC class

DESCRIPTION ^

Integer provides an integer for languages that want a value-restricted integer type without going to an I register.

Functions ^

void init()

Initializes the integer with a default value of 0.

PMC new_from_string(STRING *rep)

Class method to construct an Integer from the string representation rep.

PMC *instantiate()

Class method to construct an Integer according to passed arguments.

void share()

INTVAL get_integer()

Returns the integer value of the Integer.

INTVAL get_bool()

Returns the boolean value of the Integer.

FLOATVAL get_number()

Returns the floating-point value of the integer.

PMC *get_bignum()

Return a new BigInt PMC with the value of SELF.

STRING *get_string()

Returns the string value of the integer.

void set_integer_same(PMC *value)

void set_integer_native(INTVAL value)

Sets the value of the integer to the value of the Integer *value.

void set_number_native(FLOATVAL value)

Morphs the integer to a Float and sets the value from value.

void set_bool(INTVAL value)

Morphs the integer to a Boolean and sets the value from value.

void set_bigint_int(INTVAL value)

Morphs the integer to a BigInt and sets the value from value.

void set_string_native(STRING *value)

Morphs the integer to a String and sets the value from value.

PMC *add(PMC *value, PMC *dest)

PMC *add_int(INTVAL value, PMC *dest)

Adds value to the integer and returns the result in *dest.

Please note: the label syntax MMD_type: denote the behavior, if the right hand value is of that type. The part inside the braces is converted to a distinct function and gets mmd_registered for these two types.

void i_add(PMC *value)

void i_add(INTVAL value)

void i_add(FLOATVAL value)

Adds value to SELF inplace.

PMC *subtract(PMC *value, PMC *dest)

Subtracts *value from the integer and returns the result in *dest. If dest is NULL, a new int PMC is created.

Please note: as SELF or value maybe be subclassed, we have to call get_integer and set_integer_native always.

PMC *subtract_int(INTVAL value, PMC *dest)

Subtracts value from the integer and returns the result in *dest.

void i_subtract(PMC *value)

void i_subtract_int(INTVAL value)

void i_subtract_float(FLOATVAL value)

Subtracts value from SELF inplace.

PMC *multiply(PMC *value, PMC *dest)

PMC *multiply_int(INTVAL value, PMC *dest)

Multiplies the integer by *value and returns the result in *dest.

void i_multiply(PMC *value)

void i_multiply_int(INTVAL value)

void i_multiply_float(FLOATVAL value)

Multiply value with SELF inplace.

PMC *divide(PMC *value, PMC *dest)

PMC *divide_int(INTVAL value, PMC *dest)

PMC *divide_float(FLOATVAL value, PMC *dest)

Divides the number by value and returns the result in *dest.

void i_divide(PMC *value)

void i_divide_int(INTVAL value)

void i_divide_float(FLOATVAL value)

Divides SELF by value inplace.

PMC *floor_divide(PMC *value, PMC *dest)

PMC *floor_divide_int(INTVAL value, PMC *dest)

PMC *floor_divide_float(FLOATVAL value, PMC *dest)

Divides the number by value and returns the result in *dest.

void i_floor_divide(PMC *value)

void i_floor_divide_int(INTVAL value)

void i_floor_divide_float(FLOATVAL value)

Divides SELF by value inplace.

PMC *cmodulus(PMC *value, PMC *dest)

PMC *cmodulus(INTVAL value, PMC *dest)

PMC *cmodulus(FLOATVAL value, PMC *dest)

Calculates the value of the number C-style mod value and returns the result in dest.

void i_cmodulus(PMC *value)

void i_cmodulus(INTVAL value)

void i_cmodulus(FLOATVAL value)

Calculates the value of the number C-style mod value and returns the result in dest.

PMC *modulus(PMC *value, PMC *dest)

PMC *modulus(INTVAL value, PMC *dest)

PMC *modulus(FLOATVAL value, PMC *dest)

Calculates the value of corrected mod value and returns the result in dest. See also ops/math.ops.

void i_modulus(PMC *value)

void i_modulus(INTVAL value)

void i_modulus(FLOATVAL value)

Calculates modulus inplace

PMC *pow(PMC *value, PMC *dest)

PMC *pow_int(INTVAL value, PMC *dest)

Return SELF to the valueth power and return result in dest.

void i_pow(PMC *value)

void i_pow_int(INTVAL value)

Rise SELF to the valueth power.

TODO Complex and BigInt rhs.

INTVAL is_equal (PMC *value)

The == operation.

INTVAL cmp(PMC *value)

Returns the result of comparing the integer with *value.

INTVAL cmp_num(PMC *value)

Returns the result of numerically comparing the integer with *value.

void increment()

Increments the integer.

void decrement()

Decrements the integer.

PMC *absolute(PMC *dest)

void absolute()

Sets dest to the absolute value of SELF.

void freeze(visit_info *info)

Used to archive the integer.

void thaw(visit_info *info)

Used to unarchive the integer.


parrot