mirror of
https://github.com/chylex/Brotli-Builder.git
synced 2024-09-07 20:42:46 +02:00
17 lines
434 B
C#
17 lines
434 B
C#
namespace BrotliLib.Numbers{
|
|
public static class Log2{
|
|
/**
|
|
* Calculates log2 of an integer. Returns the result rounded down to the nearest integer, or 0 if the provided value is <= 0.
|
|
*/
|
|
public static byte Floor(int value){
|
|
byte result = 0;
|
|
|
|
while((value >>= 1) > 0){
|
|
++result;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|