codewitch-honey-crisis / htcw_bits

MIT License
0 stars 0 forks source link

Apparent Bug #1

Closed PaltryProgrammer closed 2 months ago

PaltryProgrammer commented 2 months ago

greetings kind regards please see attached image . it is the result of testing bits::shift_left . there seems to be an error w/said routine . std::bitset is utilized as a reference . i am uncertain as to meaning of "offset_bits" argument . from brief study of code it seems to be the number of lower bits to not shift , the tests utilize a value of 0 . also attached is the test code for purpose of reproduction . thank you kindly

main.cpp.txt

htcw Bits Error

codewitch-honey-crisis commented 2 months ago

Thanks for that. I'll look into this. I didn't test it directly I'm ashamed to say. I tested via my bitmap code in my graphics library, which it seems to work for, so I'm thankful for your repro. I'll get to it when it cools off some here and I can think. Thanks again!

PaltryProgrammer commented 2 months ago

greetings kind regards i seem to have finally gotten my own left shift code to work w/o error . it is attached if you would like to have a look at it . also the attached code rather thoroughly tests mine and htcw code . i am surprised it reports no errors of mine but am even more surprised and am sorry to say reports quite a large number of htcw errors . perhaps i am in error as to how to utilize htcw code if so i apologize for troubling your kind self . kind regards main.cpp.txt

codewitch-honey-crisis commented 2 months ago

Thanks for all that. bits requires C++14 or C++17 to compile, and should work with MSVC2022 or later. If you're getting errors after that, it must be something with your compiler settings?

PaltryProgrammer commented 2 months ago

Greetings & Kind Regards

I am sorry but I must find great fault w/ the bits::shift_left code. Please permit me to elaborate.

re/ line 498 *pdst = (src << shift_bits) | (src2 >> (8 - shift_bits)); I can not comprehend why it is affecting the lower order byte w/ the value in the next higher byte whilst performing a left shift.

re/ all the code from line 492 to end of routine It seems to be unconcerned w/ the intermediate bytes other than the lowest order and highest order w/ the presumed possible result the transfer of bits from a lower order byte to the next higher byte does not occur.

re/ line 504 --pend; is pend to be utilized? it does not appear further.

By the way the previous file I provided contained an error. I provide it again w/ the correction.

As for compiler settings I never fiddle w/ those as I know little re/ same. However it is C++20.

main.cpp.txt

Kind Regards

PaltryProgrammer commented 2 months ago

Hello again. Sorry to trouble your kind self. May I please inquire does bits assume large endian. I tested assuming little. Thank You Kindly

PaltryProgrammer commented 2 months ago

Greetings & Kind Regards

May I suggest a simple test of bits::shift_left as I am now convinced it is not correct. Attached please find my own result of such a test and the test values. On the face of it it seems to shift in 1s instead of 0, which I believe is not the correct procedure. However that is not how that extra 1 got into the lower byte. It got there because it is being or'd via the upper byte in line 498 for reasons I can not comprehend.

Kind Regards

htcw bits shift_left failure

codewitch-honey-crisis commented 2 months ago

I'm just going to have to rewrite the whole thing, and then regression test my graphics library that uses it. I haven't gotten to it yet part because I was visiting my family yesterday. Thanks for all this.

PaltryProgrammer commented 2 months ago

Greetings & Kind Regards

May I suggest utilizing my own version also my test code. I would be honored if your kind self would even consider such.

codewitch-honey-crisis commented 2 months ago

I'd have to modify it first, as I need the offset bits parameter - it needs to be able to shift on non-byte boundaries. But I'll take a look at it, thanks.

PaltryProgrammer commented 1 month ago

Greetings & Kind Regards May I inquire have you investigated further the behavior of your bit shift code. Is it in fact in error. If in error and not yet repaired I humbly offer my paltry services to re-write my own code so as to operate on non-byte boundaries. Kind Regards

codewitch-honey-crisis commented 1 month ago

I haven't yet, sorry