diff options
Diffstat (limited to 'src/include/util/algorithm.H')
| -rw-r--r-- | src/include/util/algorithm.H | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/include/util/algorithm.H b/src/include/util/algorithm.H index 54baa029d..dac0f47c9 100644 --- a/src/include/util/algorithm.H +++ b/src/include/util/algorithm.H @@ -5,7 +5,9 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2012,2014 */ +/* Contributors Listed Below - COPYRIGHT 2012,2015 */ +/* [+] International Business Machines Corp. */ +/* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ /* you may not use this file except in compliance with the License. */ @@ -52,6 +54,20 @@ namespace Util static const T value = (a > b) ? a : b; }; + /** + * @brief - utility function that determines if a given number is + * power of 2. + * + * @param[in] i_num - given number. + * + * @return bool - True if the number is a power of 2, False otherwise. + */ + template <typename T> + bool isPow2(T i_num) + { + return (!(i_num & (i_num-1))); + } + }; }; #endif |

