NAME

src/pmc/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

static void maybe_throw_overflow_error(PARROT_INTERP)
Checks to see if the interpreter is set to throw an exception on overflow.If so, throw the exception, otherwise ignore.
static PMC* upgrade_self_to_bignum(PARROT_INTERP, PMC *self)
Returns a pointer of *self upgraded to a bignum
PMC init_pmc(PMC *init)
Create a new Integer with arguments passed according to pdd03.
void init()
Initializes the integer with a default value of 0.
PMC *clone()
Creates an exact duplicate of this PMC.
void *get_pointer()
Return the memory address of an Integer PMC. This is needed for certain NCI applications and may be disabled in certain security contexts.
void set_pmc(PMC *value)
Sets the value of the integer to the value in *value.
void share()
Sets this PMC as shared and read-only.
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.
STRING *get_string()
STRING *get_repr()
Returns the string value of the integer.
void set_integer_native(INTVAL value)
Sets the value of the integer to the value of the native 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_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.
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 PMC of this type.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 *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 in place.
PMC *neg(PMC *dest)
void i_neg()
Set dest to the negated value of SELF. If the value of SELF is the minimum integer, a BigInt is created.
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. If the value of SELF is the minimum integer, a BigInt is created.
STRING *get_as_base(INTVAL base)
Converts and returns the integer in base base. base must be between 2 and 36, inclusive.
void freeze(PMC *info)
Used to archive the integer.
void thaw(PMC *info)
Used to unarchive the integer.
void set_random(from, to)
Set to a random value.
    SELF.set_random()       # value from [INTVAL_MIN..INTVAL_MAX]
    SELF.set_random(0)      # same
    SELF.set_random(a)      # value from [0..a] or [a..0] if a is negative
    SELF.set_random(a, b)   # value from [a..b] (b > a)