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
- 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
- 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
- void set_number_native(FLOATVAL value)Morphs the integer to a
- void set_bool(INTVAL value)Morphs the integer to a
- void set_string_native(STRING *value)Morphs the integer to a
- PMC *add(PMC *value, PMC *dest)
- PMC *add_int(INTVAL value, PMC *dest)Adds
- void i_add(PMC *value)
- void i_add(INTVAL value)
- void i_add(FLOATVAL value)Adds
- PMC *subtract(PMC *value, PMC *dest)Subtracts
- PMC *subtract_int(INTVAL value, PMC *dest)Subtracts
- void i_subtract(PMC *value)
- void i_subtract_int(INTVAL value)
- void i_subtract_float(FLOATVAL value)Subtracts
- PMC *multiply(PMC *value, PMC *dest)
- PMC *multiply_int(INTVAL value, PMC *dest)Multiplies the integer by
- void i_multiply(PMC *value)
- void i_multiply_int(INTVAL value)
- void i_multiply_float(FLOATVAL value)Multiply
- PMC *divide(PMC *value, PMC *dest)
- PMC *divide_int(INTVAL value, PMC *dest)
- PMC *divide_float(FLOATVAL value, PMC *dest)Divides the number by
- void i_divide(PMC *value)
- void i_divide_int(INTVAL value)
- void i_divide_float(FLOATVAL value)Divides
- 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
- void i_floor_divide(PMC *value)
- void i_floor_divide_int(INTVAL value)
- void i_floor_divide_float(FLOATVAL value)Divides
- PMC *modulus(PMC *value, PMC *dest)
- PMC *modulus(INTVAL value, PMC *dest)
- PMC *modulus(FLOATVAL value, PMC *dest)Calculates the value of corrected
- 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
- INTVAL is_equal(PMC *value)The
- INTVAL cmp(PMC *value)Returns the result of comparing the integer with
- INTVAL cmp_num(PMC *value)Returns the result of numerically comparing the integer with
- void increment()Increments the integer.
- void decrement()Decrements the integer.
- PMC *absolute(PMC *dest)
- void absolute()Sets
- STRING *get_as_base(INTVAL base)Converts and returns the integer in base
- 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.
0.
*value.
*value.
Float and sets the value from value.
Boolean and sets the value from value.
String and sets the value from value.
value to the integer and returns the result in *dest.
value to SELF inplace.
*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.
value from the integer and returns the result in *dest.
value from SELF inplace.
*value and returns the result in *dest.
value with SELF inplace.
value and returns the result in *dest.
SELF by value inplace.
value and returns the result in *dest.
SELF by value inplace.
mod value and returns the result in dest.
See also ops/math.ops.
dest to the negated value of SELF.
If the value of SELF is the minimum integer,
a BigInt is created.
== operation.
*value.
*value.
dest to the absolute value of SELF.
If the value of SELF is the minimum integer,
a BigInt is created.
base.
base must be between 2 and 36,
inclusive.
    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)
