noporpoise / bitarray Goto Github PK
View Code? Open in Web Editor NEWC bit array structs and methods
License: Creative Commons Zero v1.0 Universal
C bit array structs and methods
License: Creative Commons Zero v1.0 Universal
Hi,
It seems that there is an issue in the function
static word_t __inline windows_popcount(word_t w)
{
w = w - ((w >> 1) & (word_t)~(word_t)0/3);
w = (w & (word_t)~(word_t)0/15_3) + ((w >> 2) & (word_t)~(word_t)0/15_3);
w = (w + (w >> 4)) & (word_t)~(word_t)0/255*15;
c = (word_t)(w \* ((word_t)~(word_t)0/255)) >> (sizeof(word_t) - 1) \* 8;
}
line 170 in bit_array.c
Best Regards,
Long Yuan
Add bit_array_find_next_set_bit()
, a generalised version of bit_array_find_first_set_bit()
.
If I add 8 bytes to a bit array:
55 31 5A 12 02 31 C3 1E
And then print the bit array's words[0] with printf( "%016" PRIx64"", val ):
1ec33102125a3155
And then I loop through the bits with:
for ( int idx = 0; idx < 64; idx++ )
{
if ( bit_array_get_bit( ba, idx ) == 0 )
printf( "0" );
else
printf( "1" );
}
then I get (I added spaces to make it easier to see):
10101010 10001100 01011010 01001000 01000000 10001100 11000011 01111000
Which is wrong for a big-endian processor. It should be:
01010101 00110001 01011010 00010010 00000010 00110001 11000011 00011110
You can see that the order of the bits within each byte is backwards. You're assuming little-endian ordering.
Any chance you can tag a new release? Been 57 commits since 2013.
Need a comparison with std::bitset, so it's more attractive
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.