math/pow2.bi

Summary
math/pow2.bi
LicenseCopyright © 2007-2011, FreeBASIC Extended Library Development Group
ext.math
Functions
NextPow2Finds the next power of 2 after a number.
RoundPow2Finds the next power of 2 after a number only if the number passed is not a power of 2 already.
IsPow2Determines if the number passed is a power of 2.

License

Copyright © 2007-2011, FreeBASIC Extended Library Development Group

Distributed under the FreeBASIC Extended Library Group license.  See accompanying file LICENSE.txt or copy at http://code.google.com/p/fb-extended-lib/wiki/License

ext.math

Summary
Functions
NextPow2Finds the next power of 2 after a number.
RoundPow2Finds the next power of 2 after a number only if the number passed is not a power of 2 already.
IsPow2Determines if the number passed is a power of 2.

Functions

NextPow2

declare function NextPow2 overload (
   byval ds as fbext_TypeName(NumericType_)
) as fbext_TypeName(NumericType_)

Finds the next power of 2 after a number.

Overloaded to work with all numeric types.

Parameters

dsthe number to find the next power of 2 after.

Returns

The next power of 2.

RoundPow2

declare function RoundPow2 overload (
   byval n as fbext_TypeName(NumericType_)
) as fbext_TypeName(NumericType_)

Finds the next power of 2 after a number only if the number passed is not a power of 2 already.

Overloaded to work with all numeric types.

Parameters

dsthe number to find the next power of 2 after.

Returns

The next power of 2 if ds is not a power of 2, ds otherwise.

IsPow2

declare function IsPow2 overload (
   byval n as fbext_TypeName(NumericType_)
) as ext.bool

Determines if the number passed is a power of 2.

Overloaded to work with all numeric types.

Parameters

xxthe number to check.

Returns

True if the number is a power of two.

declare function NextPow2 overload (
   byval ds as fbext_TypeName(NumericType_)
) as fbext_TypeName(NumericType_)
Finds the next power of 2 after a number.
declare function RoundPow2 overload (
   byval n as fbext_TypeName(NumericType_)
) as fbext_TypeName(NumericType_)
Finds the next power of 2 after a number only if the number passed is not a power of 2 already.
declare function IsPow2 overload (
   byval n as fbext_TypeName(NumericType_)
) as ext.bool
Determines if the number passed is a power of 2.