Commit Graph

22 Commits

Author SHA1 Message Date
andri lim affbe30b41 implement compile time helpers 2019-10-23 21:55:47 +09:00
andri lim 21dc4c6519 compile time truncate and dumpHex 2019-10-23 21:55:47 +09: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
Ștefan Talpalaru 6853ebe97c
assert() -> doAssert() 2019-03-14 03:43:51 +01:00
Jacek Sieka 9027fbea3e
refactoring away for loop macros
* remove experimental for loop macro usage
* make implementation of several operations follow data structure
(recursive data -> recursive implementation)
* rename getSize -> bitsof to avoid bits vs bytes confusion
* fix potential 32-bit issue where asSignedWords cast to `int` even when
`uint64` was used as storage
* `hi` for signed ints now is signed - this replaces `asSignedWords` and
makes several int operations more natural
* fix bit size assert
2018-10-25 12:58:40 +02: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 0f5fd20679 NEP-1 (camelCase) 2018-10-08 21:11:06 +00:00
mratsim eb6357f4d1 Misse double hash for doc comments 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 7bbe7d8f9f Fix doc of toInt/toUint + add more docs about undefined behaviours 2018-10-08 21:11:06 +00:00
mratsim 69b5630de1 Use static default argument fix #40 and deprecated significantBytesBE 2018-10-08 21:11:06 +00:00
mratsim 31101a5c5b Add a toUint64 and toInt64 for 32-bit platform (fixes #48) 2018-10-08 21:11:06 +00:00
mratsim 1c29314d8e Add a touint proc fixes #58 2018-10-08 21:11:06 +00:00
Luke Parker d6435b37ef Stop single digit strings from throwing an IndexError on `parse` (#59) 2018-08-05 23:47:05 +02:00
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 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
mratsim 7c11f7da07 add `$` alias for toString 2018-05-15 11:51:59 +02:00
Yuriy Glukhov ad09fe3a94 Corrected package structure 2018-05-08 17:42:42 +03:00