summaryrefslogtreecommitdiffstatshomepage
path: root/py/objint_mpz.c
Commit message (Collapse)AuthorAge
* py/mpz: Do Python style division/modulo within bignum divmod routine.Damien George2016-05-08
| | | | | This patch consolidates the Python logic for division/modulo to one place within the bignum code.
* py: Use MP_SMALL_INT_POSITIVE_MASK to check if uint fits in a small int.Damien George2016-03-10
| | | | | Using the original WORD_MSBIT_HIGH-logic resulted in errors when the object model is not REPR_A or REPR_C.
* py: Change mp_obj_int_is_positive to more general mp_obj_int_sign.Damien George2016-01-07
| | | | This function returns the sign (-1, 0 or 1) of the integer object.
* py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR.Damien George2015-11-29
| | | | | | | | | This allows the mp_obj_t type to be configured to something other than a pointer-sized primitive type. This patch also includes additional changes to allow the code to compile when sizeof(mp_uint_t) != sizeof(void*), such as using size_t instead of mp_uint_t, and various casts.
* py: Add mp_obj_is_float function (macro) and use it where appropriate.Damien George2015-10-20
|
* py: Rename MP_BOOL() to mp_obj_new_bool() for consistency in naming.Paul Sokolovsky2015-10-11
|
* py: Catch all cases of integer (big and small) division by zero.Damien George2015-10-01
|
* py/mpz: Fix calculation of max digit storage for mpz; fix sys.maxsize.Damien George2015-09-15
| | | | | | | | When creating constant mpz's, the length of the mpz must be exactly how many digits are used (not allocated) otherwise these numbers are not compatible with dynamically allocated numbers. Addresses issue #1448.
* py: Implement divmod for mpz bignum.Damien George2015-06-13
|
* py: Convert hash API to use MP_UNARY_OP_HASH instead of ad-hoc function.Damien George2015-05-12
| | | | | | | | | | | | | | Hashing is now done using mp_unary_op function with MP_UNARY_OP_HASH as the operator argument. Hashing for int, str and bytes still go via fast-path in mp_unary_op since they are the most common objects which need to be hashed. This lead to quite a bit of code cleanup, and should be more efficient if anything. It saves 176 bytes code space on Thumb2, and 360 bytes on x86. The only loss is that the error message "unhashable type" is now the more generic "unsupported type for __hash__".
* py: Support conversion of bignum to bytes.Damien George2015-04-25
| | | | | | | This gets int.to_bytes working for bignum, and also struct.pack with 'q' and 'Q' args on 32-bit machines. Addresses issue #1155.
* py/objint_mpz.c: Make int_from_uint actually return uint.Damien George2015-04-22
|
* py: Fix builtin abs so it works for bools and bignum.Damien George2015-03-14
|
* py: Use float-to-int classifications for mp_obj_new_int_from_float() functionsDavid Steinberg2015-01-24
|
* py: Temporary fix for conversion of float to int when fits in small int.Damien George2015-01-07
| | | | Addresses issue #1044 (see also #1040). Could do with a better fix.
* py: Raise exception if trying to convert inf/nan to int.Damien George2015-01-02
|
* py: Fix float to int conversion for large exponents.David Steinberg2015-01-02
|
* py: Move to guarded includes, everywhere in py/ core.Damien George2015-01-01
| | | | Addresses issue #1022.
* py: Partially fix float to int conversion.Paul Sokolovsky2014-12-30
| | | | | | | This fixes conversion when float type has more mantissa bits than small int, and float value has small exponent. This is for example the case of 32-bit platform using doubles, and converting value of time.time(). Conversion of floats with larg exponnet is still not handled correctly.
* py: Rename mp_obj_int_get to mp_obj_int_get_truncated; fix struct.pack.Damien George2014-12-05
| | | | | | | | | | | mp_obj_int_get_truncated is used as a "fast path" int accessor that doesn't check for overflow and returns the int truncated to the machine word size, ie mp_int_t. Use mp_obj_int_get_truncated to fix struct.pack when packing maximum word sized values. Addresses issues #779 and #998.
* mpz: Fix 64bit msvc buildstijn2014-10-30
| | | | | | msvc does not treat 1L a 64bit integer hence all occurences of shifting it left or right result in undefined behaviour since the maximum allowed shift count for 32bit ints is 31. Forcing the correct type explicitely, stored in MPZ_LONG_1, solves this.
* py: Convert [u]int to mp_[u]int_t where appropriate.Damien George2014-10-03
| | | | Addressing issue #50.
* py: Enable struct/binary-helper to parse q and Q sized ints.Damien George2014-09-10
| | | | Addresses issue #848.
* py: Correctly set sys.maxsize value for 64-bit.Paul Sokolovsky2014-09-06
| | | | | | Type representing signed size doesn't have to be int, so use special value which defaults to SSIZE_MAX, but as it's not defined by C standard (but rather by POSIX), allow ports to set it.
* py: Fix definition of sys.maxsize with mpz changes.Damien George2014-09-06
|
* py: Convert (u)int to mp_(u)int_t in mpz, and remove unused function.Damien George2014-09-05
|
* py: Change all uint to mp_uint_t in obj.h.Damien George2014-08-30
| | | | Part of code cleanup, working towards resolving issue #50.
* Change some parts of the core API to use mp_uint_t instead of uint/int.Damien George2014-08-30
| | | | Addressing issue #50, still some way to go yet.
* py: Improve handling of long-int overflow.Damien George2014-07-31
| | | | | | | | | | This removes mpz_as_int, since that was a terrible function (it implemented saturating conversion). Use mpz_as_int_checked and mpz_as_uint_checked. These now work correctly (they previously had wrong overflow checking, eg print(chr(10000000000000)) on 32-bit machine would incorrectly convert this large number to a small int).
* py: Make long ints hashable.Damien George2014-07-24
| | | | Addresses issue #765.
* py: Implement sys.maxsize, standard way to check platform "bitness".Paul Sokolovsky2014-07-03
| | | | | Implementing it as a static constant is a bit peculiar and require cooperation from long int implementation.
* Rename machine_(u)int_t to mp_(u)int_t.Damien George2014-07-03
| | | | See discussion in issue #50.
* py: Separate MICROPY_PY_BUILTINS_COMPLEX from MICROPY_PY_BUILTINS_FLOAT.Paul Sokolovsky2014-06-20
| | | | | One thing is wanting to do 1 / 2 and get something else but 0, and quite another - doing rocket science ;-).
* Rename bultins config variables to MICROPY_PY_BUILTINS_*.Damien George2014-06-01
| | | | | | | | | | This renames: MICROPY_PY_FROZENSET -> MICROPY_PY_BUILTINS_FROZENSET MICROPY_PY_PROPERTY -> MICROPY_PY_BUILTINS_PROPERTY MICROPY_PY_SLICE -> MICROPY_PY_BUILTINS_SLICE MICROPY_ENABLE_FLOAT -> MICROPY_PY_BUILTINS_FLOAT See issue #35 for discussion.
* py: Fix check of small-int overflow when parsing ints.Damien George2014-05-28
| | | | Also unifies use of SMALL_INT_FITS macro across parser and runtime.
* py: Implement long int parsing in int(...).Damien George2014-05-28
| | | | Addresses issue #627.
* py: Rename MP_OBJ_NOT_SUPPORTED to MP_OBJ_NULL.Damien George2014-05-21
| | | | See issue #608 for justification.
* py: More const usage.Paul Sokolovsky2014-05-17
|
* py: Tidy up returning NULL which should be MP_OBJ_NOT_SUPPORTED.Damien George2014-05-10
|
* py: Improve native emitter; now supports more opcodes.Damien George2014-05-07
|
* Add license header to (almost) all files.Damien George2014-05-03
| | | | | | | Blanket wide to all .c and .h files. Some files originating from ST are difficult to deal with (license wise) so it was left out of those. Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
* py, unix: Make "mpconfig.h" be first included, as other headers depend on it.Paul Sokolovsky2014-05-02
| | | | Specifically, nlr.h does.
* py: Add MP_OBJ_STOP_ITERATION and make good use of it.Damien George2014-04-17
| | | | | Also make consistent use of MP_OBJ_NOT_SUPPORTED and MP_OBJ_NULL. This helps a lot in debugging and understanding of function API.
* py: Remove useless implementations of NOT_EQUAL in binary_op's.Damien George2014-04-12
| | | | | | | I'm pretty sure these are never reached, since NOT_EQUAL is always converted into EQUAL in mp_binary_op. No one should call type.binary_op directly, they should always go through mp_binary_op (or mp_obj_is_equal).
* py: Make it so that printing a small int does not allocate heap memory.Damien George2014-04-08
| | | | | | | | | | | | | | With the implementation of proper string formatting, code to print a small int was delegated to mpz_as_str_inpl (after first converting the small int to an mpz using stack memory). But mpz_as_str_inpl allocates heap memory to do the conversion, so small ints needed heap memory just to be printed. This fix has a separate function to print small ints, which does not allocate heap, and allocates less stack. String formatting, printf and pfenv are now large beasts, with some semi-duplicated code.
* Add string formatting support for longlong and mpz.Dave Hylands2014-04-07
|
* py: Change nlr_jump to nlr_raise, to aid in debugging.Damien George2014-04-05
| | | | | | This does not affect code size or performance when debugging turned off. To address issue #420.
* py: Make False and True act like 0 and 1 for integer arithmetic.Damien George2014-04-04
|
* py: This time, real proper overflow checking of small int power.Damien George2014-04-04
| | | | Previous overflow test was inadequate.
* py: More robust int conversion and overflow checking.Damien George2014-04-03
|