GCC has the __builtin_clzll
builtin function that according to https://www.geeksforgeeks.org/builtin-functions-gcc-compiler/:
__builtin_clz(x): This function is used to count the leading zeros of the integer. Note : clz = count leading zero’s
I think LLVM also has these functions, and Rust is compiled with LLVM. Is there a way to use this function in Rust?
kornel
November 9, 2021, 4:49pm
#2
There's leading_zeros
method on integers. It most likely compiles to the same thing. Use rust.godbolt.org to verify (remember to add -O
to options on godbolt)
3 Likes
system
closed
February 7, 2022, 5:34pm
#5
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.