This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A quick and dirty hack to caluclate 32-bit fixed-point log2 at compile-time | |
// for defining constants and doing template metaprogramming where a fractional | |
// result is required. | |
// Apart from the static assertion, this code can be used even in C++98. | |
// | |
// NOTE: The first argument to `FixedPointLog2` should already be in fixed-point | |
// form (e.g. in order to calculate the log2 of 3 with the result in the | |
// form s15.16, you should use `FixedPointLog2<(3 << 16), 16>`. | |
#include <stddef.h> |
OlderNewer