From c78904b97e080d9529c436e33fa7b7d2b7e88eca Mon Sep 17 00:00:00 2001 From: Guillaume Piolat Date: Thu, 25 Jun 2026 01:23:12 +0200 Subject: [PATCH] For nu_bsf and nu_bsr, match the return type of core.bitop.bsr and core.bitop.bsf. Rationale: nurt user does import core.bitop; so expects similar signature, unless I'm mistaken. int is also enough. --- source/numem/core/math.d | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/numem/core/math.d b/source/numem/core/math.d index 3c74f58..abf146d 100644 --- a/source/numem/core/math.d +++ b/source/numem/core/math.d @@ -94,7 +94,7 @@ 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; @@ -102,7 +102,7 @@ if (__traits(isIntegral, T)) { } 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) @@ -128,7 +128,7 @@ 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; @@ -136,7 +136,7 @@ if (__traits(isIntegral, T)) { } else { // Slow software implementation. - uint offset = 0; + int offset = 0; T mask = 1; foreach(i; 0..T.sizeof*8) { if (value & mask)