"Sputnik" help  
Sputnik Help
IsolateHighBit(<value>)

Description

Isolates the highest set bit in an unsigned 64-bit integer value.

Parameters

<value> The unsigned 64-bit integer value to isolate the highest set bit.

Return Value

Success: Returns true.
Failure: Returns false.

Remarks

This function isolates the highest set bit in the given unsigned 64-bit integer value. It uses a loop to clear all the lower set bits by performing a bitwise AND operation with (value - 1) until only the highest set bit remains. If the value is zero, indicating no set bits, the function returns zero.

Related

Example

Example of usage:

my $value1 = 10; // Binary: 1010
my $isolated1 = IsolateHighBit($value1);
say $isolated1;

my $value2 = 0; // No set bits
my $isolated2 = IsolateHighBit($value2);
say $isolated2;

my $value3 = 255; // Binary: 11111111
my $isolated3 = IsolateHighBit($value3);
say $isolated3;

// PRINTS
// 8
// 0
// 128

 


Contact
Cheryl (uberfox@hotmail.com)
Homepage
http://ubersoft.org