Commit Graph

77 Commits

Author SHA1 Message Date
andri lim 5b9e73e488 improve uint comparison coverage + compile time test 2019-10-23 21:55:47 +09:00
andri lim 84466dae0a improve int comparison coverage + compile time test 2019-10-23 21:55:47 +09:00
andri lim 07411e31a5 fixes test_uint_addsub typo 2019-10-23 21:55:47 +09:00
andri lim f902d117fc improve int bitwise coverage + compile time test 2019-10-23 21:55:47 +09:00
andri lim 332f7b1f04 improve uint bitwise coverage + compile time test 2019-10-23 21:55:47 +09:00
andri lim 79dfae7d32 fixes typo 2019-10-23 21:55:47 +09:00
andri lim 057fb45f12 improve uint addsub coverage + compile time test 2019-10-23 21:55:47 +09:00
andri lim 4aff306a6f improve int addsub coverage + compile time test 2019-10-23 21:55:47 +09:00
andri lim 3189775012 fixes 32bit failure 2019-10-23 21:55:47 +09:00
andri lim 0cd6b2a052 improve io test coverage + compile time test 2019-10-23 21:55:47 +09:00
andri lim 523b74d0d2 add endians2 test into all_tests 2019-10-23 21:55:47 +09:00
andri lim 7921712db1 improve endians2 test coverage + compile time test 2019-10-23 21:55:47 +09:00
andri lim de17e63b85 improve bitops test coverage + compile time test 2019-10-23 21:55:47 +09:00
andri lim 6eb7b7054e
fixes related to Nim v1.0.2 32 bit type inference rule modification 2019-10-19 16:56:18 +07:00
andri lim 173699583b
fix #81 remove ashr from API and fix shr on Nim 0.20 2019-08-06 20:25:48 +07:00
Jacek Sieka c5247e9d88
stew updates (#82)
* simplify int api (fixes #68)
* implement endians api
* implement some more bitops
2019-07-22 09:53:58 +02:00
andri lim ccf87daac1 implement arithmetic right shift (#76)
* implement arithmetic right shift

* workaround Nim VM 'cast' limitation

* fix high(stint) bug

* fix compile time bit shift bug

* add test for compile time shift and high(stint)

* add tests against ttmath
2019-05-11 15:44:41 +02:00
Jacek Sieka 9c51f9e7d5 use bitops2 from shims (#77) 2019-05-09 21:46:40 +02:00
Ștefan Talpalaru 6853ebe97c
assert() -> doAssert() 2019-03-14 03:43:51 +01:00
Jacek Sieka 360d01d170 Better bitsof implementation (#74)
See https://github.com/nim-lang/Nim/issues/9494
2019-01-07 20:11:45 +01:00
mratsim 023007b2ef Change to stint_test in property based testing 2018-12-04 15:37:37 +01:00
mratsim eb9c650d25 Add more test cases to modular exponentiation 2018-12-04 11:29:36 +01:00
Jacek Sieka edb1ade373
add a few more overloads for calculating bitset size (for eth-bloom) 2018-11-07 09:18:25 -06:00
mratsim 4fe901d33b Use truncate instead of toInt and co 2018-10-08 21:11:06 +00:00
mratsim 2d6ea71657 BREAKING: Change named param from `base` to `radix` in io procs 2018-10-08 21:11:06 +00:00
mratsim 53ceaffdfa Fix endianness issue in toInt64 and toUint64 2018-10-08 21:11:06 +00:00
mratsim f161454309 Add tests for toUint/toUint64, toInt, toInt64 2018-10-08 21:11:06 +00:00
mratsim 7591373f15 Enable modular arithmetic tests 2018-10-08 21:11:06 +00:00
mratsim 582466b625 Fix Generic Instantiation too nested in unittest (https://github.com/status-im/nim-stint/pull/66#issuecomment-427557655) + Renable all tests 2018-10-08 21:11:06 +00:00
mratsim f7fcecb395 Export marker + assign to result.data + fix forward decl and visibility issues introduced by the removal of the templates 2018-10-08 21:11:06 +00:00
zah f05feeb865 Relaxed construction from BE bytes (#57)
* Support automatic padding when constructing values from byte arrays

* add a test case for fromBytesBE
2018-07-04 17:34:14 +02:00
zah 6ae8de932d Add explicit generic conversion operators (#56)
The new `to` operators that can be used to constuct Stint types from
regular integer types. These are intented for usage in generic code
such as rlp.nim

Also fixes a bug preventing construction of Stint values from unsigned
integers (because they lack an unary `-` operator).
2018-06-27 12:18:48 +02:00
Mamy Ratsimbazafy f2d0eab153
Modular arithmetic (#47)
* Add isEven and isOdd functions

* Add modular add, mul, sub pow fixes #18
2018-05-16 10:41:46 +02:00
mratsim 7c11f7da07 add `$` alias for toString 2018-05-15 11:51:59 +02:00
mratsim 1283d582a1 implement a pow for x, y: UintImpl as well 2018-05-14 19:44:39 +02:00
Mamy Ratsimbazafy 11f62d42c9
Add exponentiation - closes #37 (#46)
* Add exponentiation

* Change name to pow (like ttmath) - `^` to discuss
2018-05-14 19:02:39 +02:00
Yuriy Glukhov ad09fe3a94 Corrected package structure 2018-05-08 17:42:42 +03:00
mratsim 012dcf288c Add toHex shortcut for toString(16) 2018-05-08 14:44:07 +02:00
Mamy Ratsimbazafy adb75b32b8
[IO]: Add readUintBE, hexToUint, toByteArrayBE
* Add readUintBE and toByteArrayBE proc

* Add readUintBE, hexToUint, to ByteArrayBE and reorder parse arguments + tests
2018-05-08 13:21:04 +02:00
mratsim b5e3e316cb use a more reasonable 10000 tests by default 2018-05-04 10:02:46 +02:00
mratsim 0a1129b36a Update comment displayed in property-based testing 2018-05-04 00:20:32 +02:00
mratsim 40f33238d9 Update uint256 to display the number of iterations 2018-05-04 00:14:51 +02:00
Mamy Ratsimbazafy 4c055e42a7
Add uint256 fuzz test vs TTMath (#34) + Fix multiplication carry bug #36
* Add uint256 fuzz test vs TTMath

* fix the compilation of property_based_uint256

* Fix multiplication carry bug #35

* Change comment in test
2018-05-04 00:11:07 +02:00
Zahary Karadjov c6b55f168f fix the compilation of property_based_uint256 2018-05-03 21:10:55 +03:00
mratsim b731108b1c Update Quicktest & Continuous Integration configuration to latest. 2018-05-03 11:07:33 +02:00
mratsim 18e73e7168 Merge branch 'master' of https://github.com/status-im/nim-stint 2018-05-02 18:02:17 +02:00
mratsim c9cba06db1 Make ttmath testing compile 2018-05-02 18:02:13 +02:00
Mamy Ratsimbazafy 0ee1fb3ec8
Fix #30 - modulo failures (#32)
* Add corner cases to test suite

* Add failing div2n1n case

* Fix test and fix #30

* Add to tests

* Fix failing tests due to Nim string change between Apr 27 and Apr 29 (doc: 5237ef4f52)
2018-05-02 17:49:31 +02:00
Mamy Ratsimbazafy fd0482180f
Add bigint serialization (hex and decimal) (#29)
* Add serialization for decimal and hex

* Fix carry bug in signed add

* Add parsing test

* Improve highlow for int, remove most_significant_word_mut

* make conversion toString compile

* Add division corner case test

* Remove a buggy division shortcut

* Fix decimal string conversion

* Fix hex dumping

* Fix power of 2 division (what was I thinking?)

* Add hexdump test

* Move runtime check to compile-time

* Fix static assert check

* more compile-time asserts

* Fix parsing of negative hex numbers, add test_io to the suite

* dump default to bigEndian, split toString in Stint and Stuint

* Add (failing) tests with big ints conversion

* Temporarily remove all the noInit pragma
2018-04-30 13:38:55 +02:00
mratsim 6d2562ff5f Implement absolute value and signed modulo/division 2018-04-26 12:27:02 +02:00