Commit Graph

35 Commits

Author SHA1 Message Date
Mamy Ratsimbazafy 4660dfe4a4
Use littleEndian for limb-endianness: bigEndian arch are very rare, untestable in CI, a pain to maintain and an intermediate serialization step instead of casting is cheap 2023-06-12 17:11:14 +07:00
Mamy André-Ratsimbazafy 777a84e9f5
Implement toHex/fromHex and fix `shl` 2023-06-12 17:08:20 +07:00
Mamy André-Ratsimbazafy 7f6c588ce3
Passing addition tests (however simple bitwise ops crash the int128 VM ... during compilation) 2023-06-12 17:08:20 +07:00
G f36623998f
fix(skipPrefixes): fix erroneous strip of 0b in hex numbers (#120)
* fix(skipPrefixes): fix erroneous strip of 0b in hex numbers

* refactor(skipPrefixes): normalize radix checks

* feat(stint): add tests for bin, oct, hex string conversions

* fix(stint): fix cast

* fix(stint): fix typo

* fix(stint): alternative format

* feat(stint): add test

* fix(stint): fix stint width in test
2022-10-03 12:15:45 +02:00
Kim De Mey e656ad40d1
Enable --styleCheck:usages (#118) 2022-02-24 20:09:53 +01:00
Mamy Ratsimbazafy 49d11d61b8
RangeError are actually defect and not catchable. (#111)
* RangeError are actually defect and not catchable.

* Don't use range types at runtime they throw RangeDefect
2021-10-08 10:08:56 +02:00
Mamy Ratsimbazafy 06e5c4829c
Parsing should raise CatchableError for user inputs (#110) 2021-10-06 18:53:52 +02:00
zah 9e49b00148 Define a hash function in order to support Stint keys in hash tables (#102)
* Hash stint values as byte blobs; Add a basic test for using stint keys in a table
2019-12-18 14:02:16 +01:00
andri lim f0da0406f0 tidying up range check in constructor 2019-12-13 16:19:41 +02:00
andri lim d98b77c88d fixes #94, implement conversion constructor 2019-12-13 16:19:41 +02:00
andri lim 7dc26bb714 signed integer 'fromHex' 2019-10-23 21:55:47 +09:00
andri lim 79dfae7d32 fixes typo 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 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