Commit Graph

19 Commits

Author SHA1 Message Date
Jacek Sieka 273ce152a6
bitops2: fix resizing casts (#194) 2023-06-15 13:52:54 +02:00
diegomrsantos 003fe9f0c8
remove cast warnings (#186) 2023-05-23 11:05:55 +02:00
Zahary Karadjov b55c5a6d74
Reorder the definitions to avoid a refernce to setBit before it's being defined 2022-07-14 15:11:34 +03:00
Jacek Sieka 8a405309c6
enable styleCheck:usages (#93) 2021-12-02 16:24:02 +01:00
Jacek Sieka 7d2790fdf4
fix `countZeros` (#80)
should return zeros based on bits, not bytes!
2021-04-12 22:55:09 +02:00
Jacek Sieka 5cf4feabea
leb128 + bitops fixes (#66)
Leb128 is a variable-length encoding for unsigned integers that is used
in a number of contexts - in particular, wasm, dwarf and protobuf.

This is an optimized low-level implementation that unrolls the loop
reading/writing the buffer - it is suitable to use as base for a more
specific API - no memory allocations, no exceptions.

This PR also fixes bitops2 to not raise on certaing uint->int
conversions, adapting bitops to nim 1.0 conversion rules by using a cast
instead of raising on uint->int conversion
2020-12-15 17:07:20 +02:00
jangko 999d3ca7ce
fixes bitops2: 'countOnesBuiltin' and 'parityBuiltin' when feeded 'unsigned' on 32 bit platform 2020-09-30 18:28:36 +07:00
Jacek Sieka 47ff49aae7
fix use of compiler intrinsics in endians/bitops (#54)
* fix use of compiler intrinsics in endians/bitops

* windows fix
2020-09-21 08:43:27 +02:00
jangko 9385fabe6c
fix countOnesBuiltin for vcc 32 bit 2020-06-15 21:46:01 +07:00
jangko 22fabba6df
fix bitops checkedScan and bitScan for vcc 2020-06-15 11:55:52 +07:00
Zahary Karadjov b9e847a143
Add bitops2.getBitsBE 2020-06-01 19:49:46 +03:00
Jacek Sieka 5512e89d4c a few more cleanups
* add raises to endians2, bitops2 since they sometimes call C functions
2020-04-10 22:40:00 +03:00
Jacek Sieka a36df61d2b
set, clear, toggle and change bits
* use standard bit manipulation naming
* fix signed overflow on large shifts
* add toggle
* add smoke tests
* branch-free changeBit
2019-12-20 12:49:20 +01:00
andri lim 53c1ebe9d4 fixes 'nimFirstOne' for Nim v1.0.2 2019-10-23 09:36:16 +09:00
Zahary Karadjov 9ac177db1f
Address review comments 2019-07-31 11:40:25 +03:00
Zahary Karadjov 81cbc16f15
Added bitops2.bitWidth 2019-07-31 02:24:33 +03:00
Zahary Karadjov 3fce87f0f5
Refactor the bitranges module
* The bit procs defined over number values and openarray are now part of
  the bitops2 module and use the more traditional LittleEndian indexing.

* Added BitSeq and BitArray types as defined in the ETH2 spec.
2019-07-31 02:20:49 +03:00
Jacek Sieka 7a87693eaf
refactor bitops2, add endians2 2019-07-06 20:47:08 +02:00
Jacek Sieka 0a8e95408f
std_shims->stew 2019-07-06 19:12:24 +02:00