]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/GetPowerOfTwo64.c
Revised GetPowerOfTwo32() and GetPowerOfTwo64() to be more efficient.
[mirror_edk2.git] / MdePkg / Library / BaseLib / GetPowerOfTwo64.c
index 8372a7f1361594ff413134c574edb82d4c83d26e..52d148c9244ea0b0ed3cfec73e4e0e68a556a043 100644 (file)
@@ -33,8 +33,9 @@ GetPowerOfTwo64 (
   IN      UINT64                    Operand\r
   )\r
 {\r
-  INTN                              BitPos;\r
+  if (Operand == 0) {\r
+    return 0;\r
+  }\r
 \r
-  BitPos = HighBitSet64 (Operand);\r
-  return BitPos >= 0 ? LShiftU64 (1, BitPos) : 0;\r
+  return LShiftU64 (1, HighBitSet64 (Operand));\r
 }\r