Commit Graph

111 Commits

Author SHA1 Message Date
Mamy Ratsimbazafy 8e25b30209
fix highest signed int comment 2018-05-17 09:45:42 +02:00
Mamy Ratsimbazafy c588a84f19
wrong variable net only_msb_set to only_msb_unset in high(IntImpl) 2018-05-17 09:43:41 +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 4e0724790c
Merge pull request #44 from status-im/pkg-struct
Corrected package structure
2018-05-08 20:57:37 +03:00
Yuriy Glukhov ad09fe3a94 Corrected package structure 2018-05-08 17:42:42 +03:00
mratsim 0ad3239907 Fix #45 - shl/shr "halfSize" should have the same type as the input 2018-05-08 16:38:11 +02:00
mratsim 37c969b11e Merge branch 'master' of https://github.com/status-im/nim-stint 2018-05-08 15:47:36 +02:00
mratsim 0209af26a2 Add restrict pragma for readUintBE and toByteArrayBE 2018-05-08 15:47:32 +02:00
Mamy Ratsimbazafy 78b2d5af29
32-bits - use guaranted 64-bit types in VM for mul fix #42 (#43) 2018-05-08 15:31:30 +02:00
mratsim 8cd48fc0e9 Add Appveyor badge + use the blue MIT badge 2018-05-08 15:30:58 +02:00
mratsim 012dcf288c Add toHex shortcut for toString(16) 2018-05-08 14:44:07 +02:00
mratsim c296e14dde Merge branch 'master' of https://github.com/status-im/nim-stint 2018-05-08 13:50:05 +02:00
mratsim 2efaf3e623 Export zero and one proc 2018-05-08 13:49:58 +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
Mamy Ratsimbazafy 1653a8815f
Restrict pragma: use C, C++, VCC + GCC + LLVM compatible syntax (#41) 2018-05-08 11:46:21 +02:00
mratsim 1b7423eacd Export countLeadingZeroBits 2018-05-06 23:02:50 +02:00
mratsim 7dad3f89d8 Export string parsing shortcut "u256" 2018-05-06 22:41:49 +02:00
mratsim 1ff544eabf Remove the fooPragma placeholder (for noinit) 2018-05-06 22:29:08 +02:00
mratsim 0dae6897b1 high/low was missing the internal proc 2018-05-06 22:24:51 +02:00
mratsim 8c0d830acf Export high and low proc 2018-05-06 22:19:00 +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 4a827027b7 Fix Travis script 2018-05-03 11:35:07 +02: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
mratsim d68c0bf44a Fix failing tests due to Nim string change between Apr 27 and Apr 29 (doc: 5237ef4f52) 2018-05-02 17:24:17 +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
Mamy Ratsimbazafy f520f7817b
Merge pull request #27 from status-im/signed-integers
Add Signed integers
2018-04-26 13:06:51 +02:00
mratsim 5ac6e229a0 update signed multiplication comment 2018-04-26 12:34:28 +02:00
mratsim 6d2562ff5f Implement absolute value and signed modulo/division 2018-04-26 12:27:02 +02:00
mratsim 8727adfcf6 Implement signed multi-precision multiplication + tests 2018-04-25 22:48:25 +02:00
mratsim ee02de16fd Fix one, it impacted signed int negation and uint division (why was it not catched?). Signed int pass the full test suite 2018-04-25 21:58:10 +02:00
mratsim 37ebd13dd4 Implement add, sub, neg with proper overflow detection 2018-04-25 21:21:58 +02:00
mratsim d690923310 Update Stint in header + mention unsigned vs signed int in tests 2018-04-25 21:21:25 +02:00
mratsim 0296b5eca9 Add sub, proper negate bound checking, high and low, most significant word mutation 2018-04-25 19:51:14 +02:00
mratsim 8b412b879d Add tests for negative numbers 2018-04-25 17:58:55 +02:00
mratsim b34019c0b5 Add signed initialization, bitwise ops, addition, negation 2018-04-25 17:50:53 +02:00
mratsim e2ab2dbf59 Add signed word iteration 2018-04-25 17:02:44 +02:00
mratsim 97fbe56353 Add most significant bit and isNegative proc 2018-04-25 15:41:59 +02:00
mratsim b3dedf7824 Split initialization and conversion proc 2018-04-25 14:43:24 +02:00
mratsim 40c2215804 Add the IntImpl type. Rename uint_type to datatypes 2018-04-25 14:27:55 +02:00
mratsim f189d13b42 Prefix repo with nim 2018-04-25 14:08:31 +02:00