Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
895 B

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1997.
  5. //
  6. // File: MISC.HXX
  7. //
  8. // Contents: Miscellaneous helper functions and tiny classes
  9. //
  10. // History: 21-Jul-92 BartoszM Created.
  11. //
  12. //----------------------------------------------------------------------------
  13. #pragma once
  14. //+---------------------------------------------------------------------------
  15. //
  16. // Function: Log2
  17. //
  18. // Synopsis: Calculates ceiling of binary log
  19. //
  20. // Arguments: [s]
  21. //
  22. // Returns: Number of binary digits in [s]
  23. //
  24. // History: 21-Jul-92 BartoszM Created.
  25. //
  26. //----------------------------------------------------------------------------
  27. inline unsigned Log2 ( unsigned long s )
  28. {
  29. for ( unsigned iLog2 = 0; s != 0; iLog2++ )
  30. s >>= 1;
  31. return(iLog2);
  32. }