python-on-a-chip online compiler

Dependencies:   mbed TSI

Embed: (wiki syntax)

« Back to documentation index

int.c File Reference

int.c File Reference

Integer Object Type. More...

Go to the source code of this file.

Functions

PmReturn_t int_dup (pPmObj_t pint, pPmObj_t *r_pint)
 Creates a duplicate Integer object.
PmReturn_t int_new (int32_t n, pPmObj_t *r_pint)
 Creates a new Integer object.
PmReturn_t int_positive (pPmObj_t pobj, pPmObj_t *r_pint)
 Implements the UNARY_POSITIVE bcode.
PmReturn_t int_negative (pPmObj_t pobj, pPmObj_t *r_pint)
 Implements the UNARY_NEGATIVE bcode.
PmReturn_t int_bitInvert (pPmObj_t pobj, pPmObj_t *r_pint)
 Implements the UNARY_INVERT bcode.
PmReturn_t int_print (pPmObj_t pint)
 Sends out an integer object in decimal notation with MSB first.
PmReturn_t int_printHex (pPmObj_t pint)
 Prints the Int object in ascii-coded hexadecimal out the platform output.
PmReturn_t int_pow (pPmObj_t px, pPmObj_t py, pPmObj_t *r_pn)
 Returns by reference an integer that is x raised to the power of y.
PmReturn_t int_divmod (pPmObj_t px, pPmObj_t py, uint8_t op, pPmObj_t *r_pxopy)
 Returns by reference the result of the selected operation.

Detailed Description

Integer Object Type.

Integer object type operations.

Definition in file int.c.


Function Documentation

PmReturn_t int_bitInvert ( pPmObj_t  pobj,
pPmObj_t r_pint 
)

Implements the UNARY_INVERT bcode.

Creates a new int with a value that is the bitwise inversion of the given int.

Parameters:
pobjPointer to integer to invert
r_pintReturn by reference; new integer
Returns:
Return status

Definition at line 107 of file int.c.

PmReturn_t int_divmod ( pPmObj_t  px,
pPmObj_t  py,
uint8_t  op,
pPmObj_t r_pxopy 
)

Returns by reference the result of the selected operation.

Parameters:
pxThe integer numerator
pyThe integer denominator
opThe operator selector. '/' selects division, all else is modulus.
r_pnReturn by reference; New integer with value of x / y or x % y.
Returns:
Return status

Definition at line 201 of file int.c.

PmReturn_t int_dup ( pPmObj_t  pint,
pPmObj_t r_pint 
)

Creates a duplicate Integer object.

Created specifically for the index value in FOR_LOOP.

Parameters:
pintPointer to int obj to duplicate.
r_pintReturn by ref, ptr to new int
Returns:
Return status

Definition at line 26 of file int.c.

PmReturn_t int_negative ( pPmObj_t  pobj,
pPmObj_t r_pint 
)

Implements the UNARY_NEGATIVE bcode.

Creates a new int with a value that is the negative of the given int.

Parameters:
pobjPointer to target object
r_pintReturn by ref, ptr to int
Returns:
Return status

Definition at line 90 of file int.c.

PmReturn_t int_new ( int32_t  val,
pPmObj_t r_pint 
)

Creates a new Integer object.

Parameters:
valValue to assign int (signed 32-bit).
r_pintReturn by ref, ptr to new int
Returns:
Return status

Definition at line 42 of file int.c.

PmReturn_t int_positive ( pPmObj_t  pobj,
pPmObj_t r_pint 
)

Implements the UNARY_POSITIVE bcode.

Creates a new int with the same value as the given int.

Parameters:
pobjPointer to integer object
r_pintReturn by reference, ptr to int
Returns:
Return status

Definition at line 73 of file int.c.

PmReturn_t int_pow ( pPmObj_t  px,
pPmObj_t  py,
pPmObj_t r_pn 
)

Returns by reference an integer that is x raised to the power of y.

Parameters:
pxThe integer base
pyThe integer exponent
r_pnReturn by reference; New integer with value of x ** y
Returns:
Return status

Definition at line 162 of file int.c.

PmReturn_t int_print ( pPmObj_t  pint )

Sends out an integer object in decimal notation with MSB first.

The number is preceded with a "-" when necessary.

Parameters:
pObjPtr to int object
Returns:
Return status

Definition at line 124 of file int.c.

PmReturn_t int_printHex ( pPmObj_t  pint )

Prints the Int object in ascii-coded hexadecimal out the platform output.

Parameters:
pintPointer to Int object

Definition at line 147 of file int.c.