Commit Graph

116 Commits

Author SHA1 Message Date
Zahary Karadjov 406f1aa317 Added a fromHex helper in the style of the new fromBytes APIs 2018-07-04 18:37:07 +03: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 36ec850c4f
Compile time signed ints (#55)
* Refactor asSignedWords, kill 130+ lines

* Allow signed int initialization at compiletime.

* inline procs in uint_mul

* Fix an unfortunate shadowing in high(Int)
2018-06-18 16:44:29 +02:00
Mamy Ratsimbazafy a46c62bc83
Uint - allow compile-time evaluation for all procs (#54)
* Initial commit - allow all ops at compile-time on uint.

* Update benchmark

* Delete commented ideal version of asWordsiterate, it  is obvious from the workaround (and is tracked in the PR)
2018-06-18 12:54:25 +02:00
Mamy Ratsimbazafy 184e22b659
Compile-time creation of Uint (#53)
* Start on allowing compile-time stint. Works for Uint256

* remove and reorder initUintImpl, zero and one procs

* Fix assignation of uint64 to 2xuint32, remove unsafeConv and use const for base/radix

* assign_least_significant_words shouldn't implicitly capture result

* Simplify least significant words macros
2018-06-16 18:54:40 +02:00
Mamy Ratsimbazafy 35c57de63d
lenient_stint, typo stuint vs stint in signed conversion 2018-06-14 18:42:58 +02:00
Mamy Ratsimbazafy 46e0810bd3
Add optional mixed types syntactic sugar (#49)
* Add optional mixed types syntactic sugar

* Rename to lenient_stint - remove literals specialization
2018-06-14 15:53:55 +02:00
Mamy Ratsimbazafy 7707a4b40f
Add overloads for literals only (#50) 2018-05-31 14:31:27 +02:00
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 ad09fe3a94 Corrected package structure 2018-05-08 17:42:42 +03:00