News for hackers. Stuff that matters.
Re:EABitTricks.h by pbsd on Monday December 19, 2022 @03:18PM (#34057089)
That appears to be a direct C++ translation of item 175 from HAKMEM [1]. This does not require a division and can be done much faster, see section 1.24 of [2].

[1] http://www.inwap.com/pdp10/hbaker/hakmem/hacks.html#item175

[2] https://jjj.de/fxt/fxtpage.html#fxtbook

Re:EABitTricks.h by tasty_freeze on Monday December 19, 2022 @03:31PM (#34057249)
> This does not require division...

From the link:

IDIVM D,C

Re:EABitTricks.h by pbsd on Monday December 19, 2022 @05:23PM (#34058606)
"This" as in finding the next combination. Gosper's trick does.
Re:EABitTricks.h by danbruc on Monday December 19, 2022 @07:10PM (#34059738)
The division performs a right shift, the version given in the FXT book replaces it with a while loop and has the note that one could use a bit scan and a shift. I would assume bit scan and shift is the fastest option - if accessible from the language used - but I am not sure if the loop could beat the division. Also the version from the EA library claims to - but fails to - perform the wrap around, the version in the FXT book does not try to wrap around and I would guess the version in HAKMEM also does not wrap around properly.