Skip to content

Commit

Permalink
fixed bitreverse bitforward mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
justnope committed Jan 13, 2019
1 parent 1af0a6b commit 7e36923
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/modules_dist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@
#include <intrin.h>
inline int clz(unsigned int value)
{
unsigned long trailing_zero = 0;
unsigned long leading_zero = 0;

if (_BitScanForward(&trailing_zero, value))
if (_BitScanReverse(&leading_zero, value))
{
return trailing_zero;
//_BitScanReverse return the position while GCC returns number of leading zeros
//so reverse it.
return 31 - leading_zero;
}
else
{
Expand Down

0 comments on commit 7e36923

Please sign in to comment.