Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions source/numem/core/math.d
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ auto ref T nu_max(T)(auto ref T a, auto ref T b) @nogc nothrow @trusted pure if
The index of the first bit set, value is undefined
if value is zero.
*/
T nu_bsr(T)(T value) @nogc nothrow @trusted pure
int nu_bsr(T)(T value) @nogc nothrow @trusted pure
if (__traits(isIntegral, T)) {
version(LDC) {
import ldc.intrinsics : llvm_ctlz;
return cast(int)(value.sizeof * 8 - 1 - llvm_ctlz(value, true));
} else {

// Slow software implementation.
uint offset = 0;
int offset = 0;
T mask = cast(T)~(T.max >>> 1);
foreach(i; 0..T.sizeof*8) {
if (value & mask)
Expand All @@ -128,15 +128,15 @@ if (__traits(isIntegral, T)) {
The index of the first bit set, value is undefined
if value is zero.
*/
T nu_bsf(T)(T value) @nogc nothrow @trusted pure
int nu_bsf(T)(T value) @nogc nothrow @trusted pure
if (__traits(isIntegral, T)) {
version(LDC) {
import ldc.intrinsics : llvm_cttz;
return cast(int)(llvm_cttz(value, true));
} else {

// Slow software implementation.
uint offset = 0;
int offset = 0;
T mask = 1;
foreach(i; 0..T.sizeof*8) {
if (value & mask)
Expand Down
Loading