Skip to content

Commit 308fb57

Browse files
committed
NextPowerOfTwo; s/unsigned int/long long/
`MostSignificantBit`; `s/unsigned int/long long/` `NextPowerOfTwo`; `s/int/long long/` Ensures that those functions allowed the most possible amount of values.
1 parent 01e40dc commit 308fb57

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ml_dtypes/include/float8.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,17 +1194,17 @@ template <typename T>
11941194
bool constexpr IsPowerOfTwo(T x) {
11951195
return (x != 0) && ((x & (x - 1)) == 0);
11961196
}
1197-
template <unsigned int N>
1197+
template <long long N>
11981198
constexpr unsigned int MostSignificantBit() {
11991199
unsigned int result = 0;
1200-
unsigned int x = N;
1200+
long long x = N;
12011201
while (x >>= 1) {
12021202
++result;
12031203
}
12041204
return result; // return N == 0 ? 0 : (sizeof(long long) * 8 - 1 - __builtin_clz(N));
12051205
}
12061206
// Helper for getting a bytes size which is a power of two.
1207-
template <int Size>
1207+
template <long long Size>
12081208
struct NextPowerOfTwo {
12091209
static constexpr int value = IsPowerOfTwo(Size) ? Size : 2 << MostSignificantBit<Size>();
12101210
};

0 commit comments

Comments
 (0)